<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<title>WorldModel</title>
<link href="../docs-assets/Breadcrumbs.css" rel="stylesheet" rev="stylesheet" type="text/css">
		<meta name="viewport" content="width=device-width initial-scale=1">
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta http-equiv="Content-Language" content="en-gb">

<link href="../docs-assets/Contents.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Progress.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Navigation.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Fonts.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Base.css" rel="stylesheet" rev="stylesheet" type="text/css">
<script>
MathJax = {
	tex: {
		inlineMath: '$', '$'], ['\\(', '\\)'
	},
	svg: {
		fontCache: 'global'
	}
};
</script>
<script type="text/javascript" id="MathJax-script" async
	src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js">
</script>

<link href="../docs-assets/Colours.css" rel="stylesheet" rev="stylesheet" type="text/css">
		
	</head>
	<body class="commentary-font">
		<nav role="navigation">
		<h1><a href="../index.html"><img src="../docs-assets/Inform.png" height=72> </a></h1>
<ul><li><a href="../index.html">home</a></li>
</ul><h2>Compiler</h2><ul>
<li><a href="../structure.html">structure</a></li>
<li><a href="../inbuildn.html">inbuild</a></li>
<li><a href="../inform7n.html">inform7</a></li>
<li><a href="../intern.html">inter</a></li>
<li><a href="../services.html">services</a></li>
<li><a href="../secrets.html">secrets</a></li>
</ul><h2>Other Tools</h2><ul>
<li><a href="../inblorbn.html">inblorb</a></li>
<li><a href="../inform6.html">inform6</a></li>
<li><a href="../inpolicyn.html">inpolicy</a></li>
</ul><h2>Resources</h2><ul>
<li><a href="../extensions.html">extensions</a></li>
<li><a href="../kits.html">kits</a></li>
</ul><h2>Repository</h2><ul>
<li><a href="https://github.com/ganelson/inform"><img src="../docs-assets/github.png" height=0> github</a></li>
</ul><h2>Related Projects</h2><ul>
<li><a href="https://github.com/ganelson/inweb"><img src="../docs-assets/github.png" height=0> inweb</a></li>
<li><a href="https://github.com/ganelson/intest"><img src="../docs-assets/github.png" height=0> intest</a></li>
</ul>
		</nav>
		<main role="main">
		<!-- Weave of 'WorldModel' generated by inweb -->
<div class="breadcrumbs">
    <ul class="crumbs"><li><a href="../index.html">Home</a></li><li><a href="../extensions.html">Kits</a></li><li><a href="index.html">WorldModelKit</a></li><li><b>WorldModel</b></li></ul></div>
<p class="purpose">WorldModel  Testing and changing the fundamental spatial relations.</p>

<ul class="toc"><li><a href="wrldm.html#SP1">&#167;1. The Core Tree</a></li><li><a href="wrldm.html#SP2">&#167;2. The holding relation</a></li><li><a href="wrldm.html#SP3">&#167;3. Climbing the Core Tree</a></li><li><a href="wrldm.html#SP4">&#167;4. To Decide Whether In</a></li><li><a href="wrldm.html#SP5">&#167;5. Containment Relation</a></li><li><a href="wrldm.html#SP6">&#167;6. Support Relation</a></li><li><a href="wrldm.html#SP7">&#167;7. Carrying Relation</a></li><li><a href="wrldm.html#SP8">&#167;8. Wearing Clothes</a></li><li><a href="wrldm.html#SP9">&#167;9. Having Relation</a></li><li><a href="wrldm.html#SP10">&#167;10. Making Parts</a></li><li><a href="wrldm.html#SP11">&#167;11. Movements</a></li><li><a href="wrldm.html#SP12">&#167;12. On Stage</a></li><li><a href="wrldm.html#SP13">&#167;13. Moving the Player</a></li><li><a href="wrldm.html#SP14">&#167;14. Move During Going</a></li><li><a href="wrldm.html#SP15">&#167;15. Being Everywhere</a></li><li><a href="wrldm.html#SP16">&#167;16. Testing Everywhere</a></li><li><a href="wrldm.html#SP17">&#167;17. Changing the Player</a></li><li><a href="wrldm.html#SP18">&#167;18. Floating Objects</a></li><li><a href="wrldm.html#SP19">&#167;19. Backdrop Location</a></li><li><a href="wrldm.html#SP20">&#167;20. Map Connections</a></li><li><a href="wrldm.html#SP21">&#167;21. Adjacency Relation</a></li><li><a href="wrldm.html#SP22">&#167;22. Regional Containment Relation</a></li><li><a href="wrldm.html#SP23">&#167;23. Doors</a></li><li><a href="wrldm.html#SP24">&#167;24. Visibility Relation</a></li><li><a href="wrldm.html#SP25">&#167;25. Audibility Relation</a></li><li><a href="wrldm.html#SP26">&#167;26. Touchability Relation</a></li><li><a href="wrldm.html#SP27">&#167;27. Concealment Relation</a></li></ul><hr class="tocbar">

<p class="commentary firstcommentary"><a id="SP1" class="paragraph-anchor"></a><b>&#167;1. The Core Tree.</b>Whereas I6 traditionally has a simple object tree hierarchy for containment,
support, carrying and so on, the I7 template also uses the <span class="extract"><span class="extract-syntax">component_*</span></span>
properties to provide a second tree which defines the "part of" relation.
These two trees interact in a subtle way, and it took a very long time to
work out the simplest way to express this.
</p>

<p class="commentary">The {\it core} of an object is the root of its subtree in the component
relation tree. So for a television set with a control panel which has a
button on, the core for the button (and also for the panel and the set)
will be the set. When X is a part of Y, it must be spatially in the same
position as Y, and so the spatial location of X is determined by the position
in the object tree of its core. (In effect, the spatial situation can be
found by contracting together all nodes corresponding to objects which are
parts of each other, but it would waste memory to construct such a tree:
<span class="extract"><span class="extract-syntax">CoreOfParentOfCoreOf</span></span> simulates what the <span class="extract"><span class="extract-syntax">parent</span></span> operation would be in
such a tree if it existed, wasting a little time instead.)
</p>

<p class="commentary">The {\it holder} of an object is its component parent, if it is part of
something, or its object-tree parent if it has one. It is illegal for both
of these to be non-<span class="extract"><span class="extract-syntax">nothing</span></span>, so this is unambiguous.
</p>

<p class="commentary">It is just possible for <span class="extract"><span class="extract-syntax">HolderOf</span></span> to be called before the player has been
placed into the model world, in cases where Inform is checking a past tense
condition in the opening pre-turn. We don't want to return <span class="extract"><span class="extract-syntax">nothing</span></span> then
because that would make it true that
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">HolderOf</span><span class="plain-syntax">(</span><span class="identifier-syntax">player</span><span class="plain-syntax">) == </span><span class="identifier-syntax">ContainerOf</span><span class="plain-syntax">(</span><span class="identifier-syntax">player</span><span class="plain-syntax">)</span>
</pre>
<p class="commentary">and similar conditions &mdash; thus, it would appear that in the immediate past
the player had been on the holder of the player, which is not in fact the
case.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">HolderOf</span><span class="plain-syntax"> </span><span class="identifier-syntax">o</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">InitialSituation</span><span class="plain-syntax">--&gt;</span><span class="identifier-syntax">DONE_INIS</span><span class="plain-syntax"> == </span><span class="reserved-syntax">false</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">o</span><span class="plain-syntax"> == </span><span class="identifier-syntax">InitialSituation</span><span class="plain-syntax">--&gt;</span><span class="identifier-syntax">PLAYER_OBJECT_INIS</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">InitialSituation</span><span class="plain-syntax">--&gt;</span><span class="identifier-syntax">START_OBJECT_INIS</span><span class="plain-syntax">)</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">InitialSituation</span><span class="plain-syntax">--&gt;</span><span class="identifier-syntax">START_OBJECT_INIS</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">InitialSituation</span><span class="plain-syntax">--&gt;</span><span class="identifier-syntax">START_ROOM_INIS</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">o</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">o</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K3_direction</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="reserved-syntax">nothing</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">o</span><span class="plain-syntax"> </span><span class="reserved-syntax">provides</span><span class="plain-syntax"> </span><span class="identifier-syntax">component_parent</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">o</span><span class="plain-syntax">.</span><span class="identifier-syntax">component_parent</span><span class="plain-syntax">)) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">o</span><span class="plain-syntax">.</span><span class="identifier-syntax">component_parent</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="reserved-syntax">parent</span><span class="plain-syntax">(</span><span class="identifier-syntax">o</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="reserved-syntax">nothing</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">ParentOf</span><span class="plain-syntax"> </span><span class="identifier-syntax">o</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">o</span><span class="plain-syntax">) </span><span class="identifier-syntax">o</span><span class="plain-syntax"> = </span><span class="reserved-syntax">parent</span><span class="plain-syntax">(</span><span class="identifier-syntax">o</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">o</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">CoreOf</span><span class="plain-syntax"> </span><span class="identifier-syntax">o</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">while</span><span class="plain-syntax"> (</span><span class="identifier-syntax">o</span><span class="plain-syntax"> &amp;&amp; (</span><span class="identifier-syntax">o</span><span class="plain-syntax"> </span><span class="reserved-syntax">provides</span><span class="plain-syntax"> </span><span class="identifier-syntax">component_parent</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">o</span><span class="plain-syntax">.</span><span class="identifier-syntax">component_parent</span><span class="plain-syntax">)) </span><span class="identifier-syntax">o</span><span class="plain-syntax"> = </span><span class="identifier-syntax">o</span><span class="plain-syntax">.</span><span class="identifier-syntax">component_parent</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">o</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">CoreOfParentOfCoreOf</span><span class="plain-syntax"> </span><span class="identifier-syntax">o</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">while</span><span class="plain-syntax"> (</span><span class="identifier-syntax">o</span><span class="plain-syntax"> &amp;&amp; (</span><span class="identifier-syntax">o</span><span class="plain-syntax"> </span><span class="reserved-syntax">provides</span><span class="plain-syntax"> </span><span class="identifier-syntax">component_parent</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">o</span><span class="plain-syntax">.</span><span class="identifier-syntax">component_parent</span><span class="plain-syntax">)) </span><span class="identifier-syntax">o</span><span class="plain-syntax"> = </span><span class="identifier-syntax">o</span><span class="plain-syntax">.</span><span class="identifier-syntax">component_parent</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">o</span><span class="plain-syntax">) </span><span class="identifier-syntax">o</span><span class="plain-syntax"> = </span><span class="reserved-syntax">parent</span><span class="plain-syntax">(</span><span class="identifier-syntax">o</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">while</span><span class="plain-syntax"> (</span><span class="identifier-syntax">o</span><span class="plain-syntax"> &amp;&amp; (</span><span class="identifier-syntax">o</span><span class="plain-syntax"> </span><span class="reserved-syntax">provides</span><span class="plain-syntax"> </span><span class="identifier-syntax">component_parent</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">o</span><span class="plain-syntax">.</span><span class="identifier-syntax">component_parent</span><span class="plain-syntax">)) </span><span class="identifier-syntax">o</span><span class="plain-syntax"> = </span><span class="identifier-syntax">o</span><span class="plain-syntax">.</span><span class="identifier-syntax">component_parent</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">o</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP2" class="paragraph-anchor"></a><b>&#167;2. The holding relation.</b>The following is essentially a wrapper for <span class="extract"><span class="extract-syntax">MoveObject</span></span> used by the relation
"holding".
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">MakeHolderOf</span><span class="plain-syntax"> </span><span class="identifier-syntax">F</span><span class="plain-syntax"> </span><span class="identifier-syntax">H</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">F</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K2_thing</span><span class="plain-syntax">) &amp;&amp;</span>
<span class="plain-syntax">        (</span><span class="identifier-syntax">H</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K1_room</span><span class="plain-syntax"> </span><span class="reserved-syntax">or</span><span class="plain-syntax"> </span><span class="identifier-syntax">K5_container</span><span class="plain-syntax"> </span><span class="reserved-syntax">or</span><span class="plain-syntax"> </span><span class="identifier-syntax">K6_supporter</span><span class="plain-syntax"> </span><span class="reserved-syntax">or</span><span class="plain-syntax"> </span><span class="identifier-syntax">K8_person</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">MoveObject</span><span class="plain-syntax">(</span><span class="identifier-syntax">F</span><span class="plain-syntax">, </span><span class="identifier-syntax">H</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">F</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K9_region</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">H</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K9_region</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">MoveObject</span><span class="plain-syntax">(</span><span class="identifier-syntax">F</span><span class="plain-syntax">, </span><span class="identifier-syntax">H</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">F</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K2_thing</span><span class="plain-syntax"> </span><span class="reserved-syntax">or</span><span class="plain-syntax"> </span><span class="identifier-syntax">K1_room</span><span class="plain-syntax"> </span><span class="reserved-syntax">or</span><span class="plain-syntax"> </span><span class="identifier-syntax">K3_direction</span><span class="plain-syntax"> </span><span class="reserved-syntax">or</span><span class="plain-syntax"> </span><span class="identifier-syntax">K9_region</span><span class="plain-syntax">) ||</span>
<span class="plain-syntax">        (</span><span class="identifier-syntax">H</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K2_thing</span><span class="plain-syntax"> </span><span class="reserved-syntax">or</span><span class="plain-syntax"> </span><span class="identifier-syntax">K1_room</span><span class="plain-syntax"> </span><span class="reserved-syntax">or</span><span class="plain-syntax"> </span><span class="identifier-syntax">K3_direction</span><span class="plain-syntax"> </span><span class="reserved-syntax">or</span><span class="plain-syntax"> </span><span class="identifier-syntax">K9_region</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">IssueNonThingRTP</span><span class="plain-syntax">(</span><span class="identifier-syntax">F</span><span class="plain-syntax">, </span><span class="identifier-syntax">H</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">move</span><span class="plain-syntax"> </span><span class="identifier-syntax">F</span><span class="plain-syntax"> </span><span class="reserved-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">H</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">];</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">IssueNonThingRTP</span><span class="plain-syntax"> </span><span class="identifier-syntax">X</span><span class="plain-syntax"> </span><span class="identifier-syntax">Y</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">IssueRTP</span><span class="plain-syntax">(</span><span class="string-syntax">"UsedSpatialRelationOnNonThing"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="string-syntax">"Holding, wearing and carrying are for things only."</span><span class="plain-syntax">, </span><span class="identifier-syntax">WorldModelKitRTPs</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="string-syntax">"*** Attempted to move "</span><span class="plain-syntax">, (</span><span class="identifier-syntax">the</span><span class="plain-syntax">) </span><span class="identifier-syntax">X</span><span class="plain-syntax">, </span><span class="string-syntax">" to "</span><span class="plain-syntax">, (</span><span class="identifier-syntax">the</span><span class="plain-syntax">) </span><span class="identifier-syntax">Y</span><span class="plain-syntax">, </span><span class="string-syntax">".^"</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">RoomContainerOf</span><span class="plain-syntax"> </span><span class="identifier-syntax">obj</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">LocationOf</span><span class="plain-syntax">(</span><span class="identifier-syntax">obj</span><span class="plain-syntax">);</span>
<span class="plain-syntax">];</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">MakeRoomContainerOf</span><span class="plain-syntax"> </span><span class="identifier-syntax">F</span><span class="plain-syntax"> </span><span class="identifier-syntax">H</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">F</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K2_thing</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">H</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K1_room</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">MoveObject</span><span class="plain-syntax">(</span><span class="identifier-syntax">F</span><span class="plain-syntax">, </span><span class="identifier-syntax">H</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">IssueNonThingRTP</span><span class="plain-syntax">(</span><span class="identifier-syntax">F</span><span class="plain-syntax">, </span><span class="identifier-syntax">H</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP3" class="paragraph-anchor"></a><b>&#167;3. Climbing the Core Tree.</b><span class="extract"><span class="extract-syntax">LocationOf</span></span> returns the room in which an object can be found, or <span class="extract"><span class="extract-syntax">nothing</span></span>
if it is out of play. Directions and regions are always out of play. Doors
and backdrops can be in multiple places: if they are in the current location,
then that's the answer; otherwise a two-sided door is in its "front side",
and a backdrop in the earliest declared room which it's currently in.
For a room, <span class="extract"><span class="extract-syntax">LocationOf</span></span> is necessarily itself.
</p>

<p class="commentary"><span class="extract"><span class="extract-syntax">CommonAncestor</span></span> finds the nearest object indirectly containing <span class="extract"><span class="extract-syntax">o1</span></span> and
<span class="extract"><span class="extract-syntax">o2</span></span>, or returns <span class="extract"><span class="extract-syntax">nothing</span></span> if there is no common ancestor. (This is a port
of <span class="extract"><span class="extract-syntax">CommonAncestor</span></span> from the I6 library, adapted to work on the core tree.)
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">LocationOf</span><span class="plain-syntax"> </span><span class="identifier-syntax">o</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (~~(</span><span class="identifier-syntax">o</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K1_room</span><span class="plain-syntax"> </span><span class="reserved-syntax">or</span><span class="plain-syntax"> </span><span class="identifier-syntax">K2_thing</span><span class="plain-syntax">)) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="reserved-syntax">nothing</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">o</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K4_door</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="reserved-syntax">parent</span><span class="plain-syntax">(</span><span class="identifier-syntax">o</span><span class="plain-syntax">) == </span><span class="identifier-syntax">real_location</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">real_location</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">FrontSideOfDoor</span><span class="plain-syntax">(</span><span class="identifier-syntax">o</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">o</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K7_backdrop</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="comment-syntax">print "(deciding ", (the) O, " is at ", (the) BackdropLocation(o), ") ";</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">BackdropLocation</span><span class="plain-syntax">(</span><span class="identifier-syntax">o</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">while</span><span class="plain-syntax"> (</span><span class="identifier-syntax">o</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">o</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K1_room</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">o</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">o</span><span class="plain-syntax"> = </span><span class="identifier-syntax">CoreOfParentOfCoreOf</span><span class="plain-syntax">(</span><span class="identifier-syntax">o</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="reserved-syntax">nothing</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">CommonAncestor</span><span class="plain-syntax"> </span><span class="identifier-syntax">o1</span><span class="plain-syntax"> </span><span class="identifier-syntax">o2</span><span class="plain-syntax"> </span><span class="identifier-syntax">i</span><span class="plain-syntax"> </span><span class="identifier-syntax">j</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">o1</span><span class="plain-syntax"> = </span><span class="identifier-syntax">CoreOf</span><span class="plain-syntax">(</span><span class="identifier-syntax">o1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">o2</span><span class="plain-syntax"> = </span><span class="identifier-syntax">CoreOf</span><span class="plain-syntax">(</span><span class="identifier-syntax">o2</span><span class="plain-syntax">);</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">i</span><span class="plain-syntax">=</span><span class="identifier-syntax">o1</span><span class="plain-syntax">: </span><span class="identifier-syntax">i</span><span class="plain-syntax">: </span><span class="identifier-syntax">i</span><span class="plain-syntax"> = </span><span class="identifier-syntax">CoreOfParentOfCoreOf</span><span class="plain-syntax">(</span><span class="identifier-syntax">i</span><span class="plain-syntax">))</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">j</span><span class="plain-syntax">=</span><span class="identifier-syntax">o2</span><span class="plain-syntax">: </span><span class="identifier-syntax">j</span><span class="plain-syntax">: </span><span class="identifier-syntax">j</span><span class="plain-syntax"> = </span><span class="identifier-syntax">CoreOfParentOfCoreOf</span><span class="plain-syntax">(</span><span class="identifier-syntax">j</span><span class="plain-syntax">))</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">j</span><span class="plain-syntax"> == </span><span class="identifier-syntax">i</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">j</span><span class="plain-syntax">;</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="reserved-syntax">nothing</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">IndirectlyContains</span><span class="plain-syntax"> </span><span class="identifier-syntax">o1</span><span class="plain-syntax"> </span><span class="identifier-syntax">o2</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">o1</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">while</span><span class="plain-syntax"> (</span><span class="identifier-syntax">o2</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">o1</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K1_room</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">o2</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K4_door</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">o1</span><span class="plain-syntax"> == </span><span class="identifier-syntax">FrontSideOfDoor</span><span class="plain-syntax">(</span><span class="identifier-syntax">o2</span><span class="plain-syntax">)) </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">o1</span><span class="plain-syntax"> == </span><span class="identifier-syntax">BackSideOfDoor</span><span class="plain-syntax">(</span><span class="identifier-syntax">o2</span><span class="plain-syntax">)) </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">o2</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K7_backdrop</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">o1</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K1_room</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">BackdropLocation</span><span class="plain-syntax">(</span><span class="identifier-syntax">o2</span><span class="plain-syntax">, </span><span class="identifier-syntax">o1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">o2</span><span class="plain-syntax"> = </span><span class="identifier-syntax">HolderOf</span><span class="plain-syntax">(</span><span class="identifier-syntax">o2</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">o2</span><span class="plain-syntax"> == </span><span class="identifier-syntax">o1</span><span class="plain-syntax">) </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP4" class="paragraph-anchor"></a><b>&#167;4. To Decide Whether In.</b>A curiosity, this: the I6 definition of "To decide whether in (obj - object)".
As can be seen, there are three possible interpretations of "in", depending
on the kind of object, so this could all be done with three different
definitions in the Standard Rules, so that run-time type checking would decide
which to apply: but that would produce a little overhead and make the code
for this rather common operation a bit complicated. Besides, this way we can
produce a respectable run-time problem message when the phrase is misapplied.
</p>

<p class="commentary">Note that "in X" is not equivalent to "the player is in X": the latter
uses direct containment, whereas we use indirect containment. Thus "in the
Hall" and "in the laundry-basket" are both true if the player is in a
laundry-basket in the Hall.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">WhetherIn</span><span class="plain-syntax"> </span><span class="identifier-syntax">obj</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">obj</span><span class="plain-syntax"> </span><span class="reserved-syntax">has</span><span class="plain-syntax"> </span><span class="identifier-syntax">enterable</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">IndirectlyContains</span><span class="plain-syntax">(</span><span class="identifier-syntax">obj</span><span class="plain-syntax">, </span><span class="identifier-syntax">player</span><span class="plain-syntax">)) </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">obj</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K9_region</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">TestRegionalContainment</span><span class="plain-syntax">(</span><span class="identifier-syntax">real_location</span><span class="plain-syntax">, </span><span class="identifier-syntax">obj</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">obj</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K1_room</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">obj</span><span class="plain-syntax"> == </span><span class="identifier-syntax">real_location</span><span class="plain-syntax">) </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">IssueRTP</span><span class="plain-syntax">(</span><span class="string-syntax">"TestedInForNonRoomOrRegion"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="string-syntax">"Can only test if the current location is in a room or region."</span><span class="plain-syntax">, </span><span class="identifier-syntax">WorldModelKitRTPs</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="string-syntax">"*** "</span><span class="plain-syntax">, (</span><span class="identifier-syntax">The</span><span class="plain-syntax">) </span><span class="identifier-syntax">obj</span><span class="plain-syntax">, </span><span class="string-syntax">" is neither.^"</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP5" class="paragraph-anchor"></a><b>&#167;5. Containment Relation.</b>This is the single most important relation in I7: direct containment. It is
complicated by the fact that "A is in B" is represented differently at
run-time when A is a room and B is a region, and when it isn't.
</p>

<p class="commentary">For each A there is at most one B such that "A is in B" is true. Because of
this we test the relation with a function of one variable which turns A into B,
rather than a function of two variables returning true or false. <span class="extract"><span class="extract-syntax">ContainerOf</span></span>
is that function.
</p>

<p class="commentary">I7 frequently needs to compile loops over all A such that "A is in B". In
simpler relations (such as the support relation below) it can do this efficiently
by iterating through the object-tree children of B, but for containment we
have to provide an iterator function <span class="extract"><span class="extract-syntax">TestContainmentRange</span></span>, as otherwise we
would get the wrong result when B is a region.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">ContainerOf</span><span class="plain-syntax"> </span><span class="identifier-syntax">A</span><span class="plain-syntax"> </span><span class="identifier-syntax">p</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">A</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K1_room</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">A</span><span class="plain-syntax">.</span><span class="identifier-syntax">map_region</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">A</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K2_thing</span><span class="plain-syntax"> </span><span class="reserved-syntax">or</span><span class="plain-syntax"> </span><span class="identifier-syntax">K9_region</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">p</span><span class="plain-syntax"> = </span><span class="reserved-syntax">parent</span><span class="plain-syntax">(</span><span class="identifier-syntax">A</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">p</span><span class="plain-syntax"> == </span><span class="reserved-syntax">nothing</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="reserved-syntax">nothing</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">p</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K5_container</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">p</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">p</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K1_room</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">p</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">p</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K9_region</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">p</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="reserved-syntax">nothing</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">MakeContainerOf</span><span class="plain-syntax"> </span><span class="identifier-syntax">F</span><span class="plain-syntax"> </span><span class="identifier-syntax">T</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">F</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K1_room</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K9_region</span><span class="plain-syntax">))</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">F</span><span class="plain-syntax">.</span><span class="identifier-syntax">map_region</span><span class="plain-syntax"> = </span><span class="identifier-syntax">T</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">F</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K2_thing</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K5_container</span><span class="plain-syntax"> </span><span class="reserved-syntax">or</span><span class="plain-syntax"> </span><span class="identifier-syntax">K1_room</span><span class="plain-syntax"> </span><span class="reserved-syntax">or</span><span class="plain-syntax"> </span><span class="identifier-syntax">K9_region</span><span class="plain-syntax">))</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">MoveObject</span><span class="plain-syntax">(</span><span class="identifier-syntax">F</span><span class="plain-syntax">, </span><span class="identifier-syntax">T</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">F</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K9_region</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K9_region</span><span class="plain-syntax">))</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">MoveObject</span><span class="plain-syntax">(</span><span class="identifier-syntax">F</span><span class="plain-syntax">, </span><span class="identifier-syntax">T</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">IssueRTP</span><span class="plain-syntax">(</span><span class="string-syntax">"MadeIllegalContainment"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="string-syntax">"Tried to put something into something else in an impossible way."</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">WorldModelKitRTPs</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="string-syntax">"*** Attempted to put "</span><span class="plain-syntax">, (</span><span class="identifier-syntax">the</span><span class="plain-syntax">) </span><span class="identifier-syntax">F</span><span class="plain-syntax">, </span><span class="string-syntax">" in "</span><span class="plain-syntax">, (</span><span class="identifier-syntax">the</span><span class="plain-syntax">) </span><span class="identifier-syntax">T</span><span class="plain-syntax">, </span><span class="string-syntax">".^"</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">];</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">TestContainmentRange</span><span class="plain-syntax"> </span><span class="identifier-syntax">obj</span><span class="plain-syntax"> </span><span class="identifier-syntax">e</span><span class="plain-syntax"> </span><span class="identifier-syntax">f</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">obj</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K9_region</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">objectloop</span><span class="plain-syntax"> (</span><span class="identifier-syntax">f</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K1_room</span><span class="plain-syntax"> &amp;&amp; </span><span class="identifier-syntax">f</span><span class="plain-syntax">.</span><span class="identifier-syntax">map_region</span><span class="plain-syntax"> == </span><span class="identifier-syntax">obj</span><span class="plain-syntax">)</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">f</span><span class="plain-syntax"> &gt; </span><span class="identifier-syntax">e</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">f</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="reserved-syntax">nothing</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">obj</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K5_container</span><span class="plain-syntax"> </span><span class="reserved-syntax">or</span><span class="plain-syntax"> </span><span class="identifier-syntax">K1_room</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">e</span><span class="plain-syntax"> == </span><span class="reserved-syntax">nothing</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="reserved-syntax">child</span><span class="plain-syntax">(</span><span class="identifier-syntax">obj</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="reserved-syntax">sibling</span><span class="plain-syntax">(</span><span class="identifier-syntax">e</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="reserved-syntax">nothing</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP6" class="paragraph-anchor"></a><b>&#167;6. Support Relation.</b>This then is simpler, with no need for an iterator governing searches.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">SupporterOf</span><span class="plain-syntax"> </span><span class="identifier-syntax">obj</span><span class="plain-syntax"> </span><span class="identifier-syntax">p</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">p</span><span class="plain-syntax"> = </span><span class="reserved-syntax">parent</span><span class="plain-syntax">(</span><span class="identifier-syntax">obj</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">p</span><span class="plain-syntax"> == </span><span class="reserved-syntax">nothing</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="reserved-syntax">nothing</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">p</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K6_supporter</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">p</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="reserved-syntax">nothing</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">MakeSupporterOf</span><span class="plain-syntax"> </span><span class="identifier-syntax">F</span><span class="plain-syntax"> </span><span class="identifier-syntax">H</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">F</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K2_thing</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">H</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K6_supporter</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">MoveObject</span><span class="plain-syntax">(</span><span class="identifier-syntax">F</span><span class="plain-syntax">, </span><span class="identifier-syntax">H</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">IssueNonThingRTP</span><span class="plain-syntax">(</span><span class="identifier-syntax">F</span><span class="plain-syntax">, </span><span class="identifier-syntax">H</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP7" class="paragraph-anchor"></a><b>&#167;7. Carrying Relation.</b>Only people may carry, and something worn is not in this sense carried.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">CarrierOf</span><span class="plain-syntax"> </span><span class="identifier-syntax">obj</span><span class="plain-syntax"> </span><span class="identifier-syntax">p</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">p</span><span class="plain-syntax"> = </span><span class="reserved-syntax">parent</span><span class="plain-syntax">(</span><span class="identifier-syntax">obj</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">p</span><span class="plain-syntax"> &amp;&amp; (</span><span class="identifier-syntax">p</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K8_person</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">obj</span><span class="plain-syntax"> </span><span class="reserved-syntax">hasnt</span><span class="plain-syntax"> </span><span class="identifier-syntax">worn</span><span class="plain-syntax">)) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">p</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="reserved-syntax">nothing</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">MakeCarrierOf</span><span class="plain-syntax"> </span><span class="identifier-syntax">F</span><span class="plain-syntax"> </span><span class="identifier-syntax">H</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">F</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K2_thing</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">H</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K8_person</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">give</span><span class="plain-syntax"> </span><span class="identifier-syntax">H</span><span class="plain-syntax"> ~</span><span class="identifier-syntax">worn</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">MoveObject</span><span class="plain-syntax">(</span><span class="identifier-syntax">F</span><span class="plain-syntax">, </span><span class="identifier-syntax">H</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">IssueNonThingRTP</span><span class="plain-syntax">(</span><span class="identifier-syntax">F</span><span class="plain-syntax">, </span><span class="identifier-syntax">H</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">];</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">UncarryObject</span><span class="plain-syntax"> </span><span class="identifier-syntax">X</span><span class="plain-syntax"> </span><span class="identifier-syntax">P</span><span class="plain-syntax"> </span><span class="identifier-syntax">Q</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">CarrierOf</span><span class="plain-syntax">(</span><span class="identifier-syntax">X</span><span class="plain-syntax">) == </span><span class="identifier-syntax">P</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">give</span><span class="plain-syntax"> </span><span class="identifier-syntax">X</span><span class="plain-syntax"> ~</span><span class="identifier-syntax">worn</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Q</span><span class="plain-syntax"> = </span><span class="identifier-syntax">HolderOf</span><span class="plain-syntax">(</span><span class="identifier-syntax">P</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Q</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">move</span><span class="plain-syntax"> </span><span class="identifier-syntax">X</span><span class="plain-syntax"> </span><span class="reserved-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">Q</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">remove</span><span class="plain-syntax"> </span><span class="identifier-syntax">Q</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP8" class="paragraph-anchor"></a><b>&#167;8. Wearing Clothes.</b>An object X is worn by a person P if and only if (i) the object tree <span class="extract"><span class="extract-syntax">parent</span></span>
of X is P, and (ii) X has the <span class="extract"><span class="extract-syntax">worn</span></span> attribute. In fact for I7 purposes we
are careful to ensure that (ii) happens only when (i) does in any case:
if X is moved in the object tree, or made a part of something, or removed
from play, then <span class="extract"><span class="extract-syntax">worn</span></span> is removed.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">WearObject</span><span class="plain-syntax"> </span><span class="identifier-syntax">X</span><span class="plain-syntax"> </span><span class="identifier-syntax">P</span><span class="plain-syntax"> </span><span class="identifier-syntax">opt</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">X</span><span class="plain-syntax"> == </span><span class="reserved-syntax">nothing</span><span class="plain-syntax">) </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">X</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K2_thing</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">P</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K8_person</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">X</span><span class="plain-syntax"> </span><span class="reserved-syntax">notin</span><span class="plain-syntax"> </span><span class="identifier-syntax">P</span><span class="plain-syntax">) </span><span class="identifier-syntax">MoveObject</span><span class="plain-syntax">(</span><span class="identifier-syntax">X</span><span class="plain-syntax">, </span><span class="identifier-syntax">P</span><span class="plain-syntax">, </span><span class="identifier-syntax">opt</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">give</span><span class="plain-syntax"> </span><span class="identifier-syntax">X</span><span class="plain-syntax"> </span><span class="identifier-syntax">worn</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">IssueNonThingRTP</span><span class="plain-syntax">(</span><span class="identifier-syntax">X</span><span class="plain-syntax">, </span><span class="identifier-syntax">P</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">];</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">UnwearObject</span><span class="plain-syntax"> </span><span class="identifier-syntax">X</span><span class="plain-syntax"> </span><span class="identifier-syntax">P</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">WearerOf</span><span class="plain-syntax">(</span><span class="identifier-syntax">X</span><span class="plain-syntax">) == </span><span class="identifier-syntax">P</span><span class="plain-syntax">) </span><span class="reserved-syntax">give</span><span class="plain-syntax"> </span><span class="identifier-syntax">X</span><span class="plain-syntax"> ~</span><span class="identifier-syntax">worn</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">WearerOf</span><span class="plain-syntax"> </span><span class="identifier-syntax">obj</span><span class="plain-syntax"> </span><span class="identifier-syntax">p</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">p</span><span class="plain-syntax"> = </span><span class="reserved-syntax">parent</span><span class="plain-syntax">(</span><span class="identifier-syntax">obj</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">p</span><span class="plain-syntax"> &amp;&amp; (</span><span class="identifier-syntax">p</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K8_person</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">obj</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K2_thing</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">obj</span><span class="plain-syntax"> </span><span class="reserved-syntax">has</span><span class="plain-syntax"> </span><span class="identifier-syntax">worn</span><span class="plain-syntax">)) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">p</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="reserved-syntax">nothing</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP9" class="paragraph-anchor"></a><b>&#167;9. Having Relation.</b>A person has something if and only if he either wears or carries it.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">+</span><span class="identifier-syntax">replacing</span><span class="plain-syntax">(</span><span class="identifier-syntax">from</span><span class="plain-syntax"> </span><span class="identifier-syntax">BasicInformKit</span><span class="plain-syntax">) [ </span><span class="identifier-syntax">OwnerOf</span><span class="plain-syntax"> </span><span class="identifier-syntax">obj</span><span class="plain-syntax"> </span><span class="identifier-syntax">p</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">p</span><span class="plain-syntax"> = </span><span class="reserved-syntax">parent</span><span class="plain-syntax">(</span><span class="identifier-syntax">obj</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">p</span><span class="plain-syntax"> &amp;&amp; (</span><span class="identifier-syntax">p</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K8_person</span><span class="plain-syntax">)) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">p</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="reserved-syntax">nothing</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP10" class="paragraph-anchor"></a><b>&#167;10. Making Parts.</b>Note that <span class="extract"><span class="extract-syntax">MakePart</span></span> removes the part-to-be from the object tree before
attaching it: it cannot, of course, be the core of the resulting object.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">PartOf</span><span class="plain-syntax"> </span><span class="identifier-syntax">P</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">P</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K2_thing</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">P</span><span class="plain-syntax">.</span><span class="identifier-syntax">component_parent</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="reserved-syntax">nothing</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">MakePart</span><span class="plain-syntax"> </span><span class="identifier-syntax">P</span><span class="plain-syntax"> </span><span class="identifier-syntax">Of</span><span class="plain-syntax"> </span><span class="identifier-syntax">First</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">P</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K2_thing</span><span class="plain-syntax">) &amp;&amp; ((</span><span class="identifier-syntax">Of</span><span class="plain-syntax"> == </span><span class="reserved-syntax">nothing</span><span class="plain-syntax">) || (</span><span class="identifier-syntax">Of</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K2_thing</span><span class="plain-syntax">))) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">P</span><span class="plain-syntax"> == </span><span class="identifier-syntax">player</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">IssueMadePlayerPartOfSomething</span><span class="plain-syntax">(</span><span class="identifier-syntax">Of</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="reserved-syntax">parent</span><span class="plain-syntax">(</span><span class="identifier-syntax">P</span><span class="plain-syntax">)) </span><span class="reserved-syntax">remove</span><span class="plain-syntax"> </span><span class="identifier-syntax">P</span><span class="plain-syntax">; </span><span class="reserved-syntax">give</span><span class="plain-syntax"> </span><span class="identifier-syntax">P</span><span class="plain-syntax"> ~</span><span class="identifier-syntax">worn</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Of</span><span class="plain-syntax"> == </span><span class="reserved-syntax">nothing</span><span class="plain-syntax">) { </span><span class="identifier-syntax">DetachPart</span><span class="plain-syntax">(</span><span class="identifier-syntax">P</span><span class="plain-syntax">); </span><span class="reserved-syntax">return</span><span class="plain-syntax">; }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">P</span><span class="plain-syntax">.</span><span class="identifier-syntax">component_parent</span><span class="plain-syntax">) </span><span class="identifier-syntax">DetachPart</span><span class="plain-syntax">(</span><span class="identifier-syntax">P</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">P</span><span class="plain-syntax">.</span><span class="identifier-syntax">component_parent</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Of</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">First</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Of</span><span class="plain-syntax">.</span><span class="identifier-syntax">component_child</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Of</span><span class="plain-syntax">.</span><span class="identifier-syntax">component_child</span><span class="plain-syntax"> = </span><span class="identifier-syntax">P</span><span class="plain-syntax">; </span><span class="identifier-syntax">P</span><span class="plain-syntax">.</span><span class="identifier-syntax">component_sibling</span><span class="plain-syntax"> = </span><span class="identifier-syntax">First</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">IssueNonThingRTP</span><span class="plain-syntax">(</span><span class="identifier-syntax">P</span><span class="plain-syntax">, </span><span class="identifier-syntax">Of</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">];</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">DetachPart</span><span class="plain-syntax"> </span><span class="identifier-syntax">P</span><span class="plain-syntax"> </span><span class="identifier-syntax">From</span><span class="plain-syntax"> </span><span class="identifier-syntax">Daddy</span><span class="plain-syntax"> </span><span class="identifier-syntax">O</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Daddy</span><span class="plain-syntax"> = </span><span class="identifier-syntax">P</span><span class="plain-syntax">.</span><span class="identifier-syntax">component_parent</span><span class="plain-syntax">; </span><span class="identifier-syntax">P</span><span class="plain-syntax">.</span><span class="identifier-syntax">component_parent</span><span class="plain-syntax"> = </span><span class="reserved-syntax">nothing</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Daddy</span><span class="plain-syntax"> == </span><span class="reserved-syntax">nothing</span><span class="plain-syntax">) { </span><span class="identifier-syntax">P</span><span class="plain-syntax">.</span><span class="identifier-syntax">component_sibling</span><span class="plain-syntax"> = </span><span class="reserved-syntax">nothing</span><span class="plain-syntax">; </span><span class="reserved-syntax">return</span><span class="plain-syntax">; }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Daddy</span><span class="plain-syntax">.</span><span class="identifier-syntax">component_child</span><span class="plain-syntax"> == </span><span class="identifier-syntax">P</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Daddy</span><span class="plain-syntax">.</span><span class="identifier-syntax">component_child</span><span class="plain-syntax"> = </span><span class="identifier-syntax">P</span><span class="plain-syntax">.</span><span class="identifier-syntax">component_sibling</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">P</span><span class="plain-syntax">.</span><span class="identifier-syntax">component_sibling</span><span class="plain-syntax"> = </span><span class="reserved-syntax">nothing</span><span class="plain-syntax">; </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">O</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Daddy</span><span class="plain-syntax">.</span><span class="identifier-syntax">component_child</span><span class="plain-syntax">: </span><span class="identifier-syntax">O</span><span class="plain-syntax">: </span><span class="identifier-syntax">O</span><span class="plain-syntax"> = </span><span class="identifier-syntax">O</span><span class="plain-syntax">.</span><span class="identifier-syntax">component_sibling</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">O</span><span class="plain-syntax">.</span><span class="identifier-syntax">component_sibling</span><span class="plain-syntax"> == </span><span class="identifier-syntax">P</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">O</span><span class="plain-syntax">.</span><span class="identifier-syntax">component_sibling</span><span class="plain-syntax"> = </span><span class="identifier-syntax">P</span><span class="plain-syntax">.</span><span class="identifier-syntax">component_sibling</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">P</span><span class="plain-syntax">.</span><span class="identifier-syntax">component_sibling</span><span class="plain-syntax"> = </span><span class="reserved-syntax">nothing</span><span class="plain-syntax">; </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP11" class="paragraph-anchor"></a><b>&#167;11. Movements.</b>Note that an object is detached from its component parent, if it has one,
when moved.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">+</span><span class="identifier-syntax">replacing</span><span class="plain-syntax">(</span><span class="identifier-syntax">from</span><span class="plain-syntax"> </span><span class="identifier-syntax">BasicInformKit</span><span class="plain-syntax">) [ </span><span class="identifier-syntax">MoveObject</span><span class="plain-syntax"> </span><span class="identifier-syntax">F</span><span class="plain-syntax"> </span><span class="identifier-syntax">T</span><span class="plain-syntax"> </span><span class="identifier-syntax">opt</span><span class="plain-syntax"> </span><span class="identifier-syntax">going_mode</span><span class="plain-syntax"> </span><span class="identifier-syntax">was</span><span class="plain-syntax"> </span><span class="identifier-syntax">L</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">F</span><span class="plain-syntax"> == </span><span class="reserved-syntax">nothing</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">IssueRTP</span><span class="plain-syntax">(</span><span class="string-syntax">"NothingMoved"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="string-syntax">"You can't move nothing."</span><span class="plain-syntax">, </span><span class="identifier-syntax">WorldModelKitRTPs</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">F</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K7_backdrop</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K9_region</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">give</span><span class="plain-syntax"> </span><span class="identifier-syntax">F</span><span class="plain-syntax"> ~</span><span class="identifier-syntax">absent</span><span class="plain-syntax">; </span><span class="identifier-syntax">F</span><span class="plain-syntax">.</span><span class="identifier-syntax">found_in</span><span class="plain-syntax"> = </span><span class="identifier-syntax">T</span><span class="plain-syntax">.</span><span class="identifier-syntax">regional_found_in</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">TestRegionalContainment</span><span class="plain-syntax">(</span><span class="identifier-syntax">LocationOf</span><span class="plain-syntax">(</span><span class="identifier-syntax">player</span><span class="plain-syntax">), </span><span class="identifier-syntax">T</span><span class="plain-syntax">)) </span><span class="reserved-syntax">move</span><span class="plain-syntax"> </span><span class="identifier-syntax">F</span><span class="plain-syntax"> </span><span class="reserved-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">LocationOf</span><span class="plain-syntax">(</span><span class="identifier-syntax">player</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">remove</span><span class="plain-syntax"> </span><span class="identifier-syntax">F</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">return</span><span class="plain-syntax">; }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> == </span><span class="identifier-syntax">FoundEverywhere</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">give</span><span class="plain-syntax"> </span><span class="identifier-syntax">F</span><span class="plain-syntax"> ~</span><span class="identifier-syntax">absent</span><span class="plain-syntax">; </span><span class="identifier-syntax">F</span><span class="plain-syntax">.</span><span class="identifier-syntax">found_in</span><span class="plain-syntax"> = </span><span class="identifier-syntax">FoundEverywhere</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">IssueRTP</span><span class="plain-syntax">(</span><span class="string-syntax">"BackdropMoved"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="string-syntax">"A backdrop can only be moved to a region."</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">WorldModelKitRTPs</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="string-syntax">"*** Tried to move "</span><span class="plain-syntax">, (</span><span class="identifier-syntax">the</span><span class="plain-syntax">) </span><span class="identifier-syntax">F</span><span class="plain-syntax">, </span><span class="string-syntax">" to "</span><span class="plain-syntax">, (</span><span class="identifier-syntax">the</span><span class="plain-syntax">) </span><span class="identifier-syntax">T</span><span class="plain-syntax">, </span><span class="string-syntax">".^"</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">F</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K4_door</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">IssueRTP</span><span class="plain-syntax">(</span><span class="string-syntax">"RemovedDoorFromPlay"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="string-syntax">"Tried to move a door."</span><span class="plain-syntax">, </span><span class="identifier-syntax">WorldModelKitRTPs</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K9_region</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">IssueRTP</span><span class="plain-syntax">(</span><span class="string-syntax">"NonBackdropMovedToRegion"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="string-syntax">"Only a backdrop can be moved to a region."</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">WorldModelKitRTPs</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="string-syntax">"*** Tried to move "</span><span class="plain-syntax">, (</span><span class="identifier-syntax">the</span><span class="plain-syntax">) </span><span class="identifier-syntax">F</span><span class="plain-syntax">, </span><span class="string-syntax">" to "</span><span class="plain-syntax">, (</span><span class="identifier-syntax">the</span><span class="plain-syntax">) </span><span class="identifier-syntax">T</span><span class="plain-syntax">, </span><span class="string-syntax">".^"</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> == </span><span class="identifier-syntax">FoundEverywhere</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">IssueBackdropOnlyRTP</span><span class="plain-syntax">(</span><span class="identifier-syntax">F</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (~~(</span><span class="identifier-syntax">F</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K2_thing</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">IssueRTP</span><span class="plain-syntax">(</span><span class="string-syntax">"NonThingMoved"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="string-syntax">"Only things can move around."</span><span class="plain-syntax">, </span><span class="identifier-syntax">WorldModelKitRTPs</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="string-syntax">"*** Tried to move "</span><span class="plain-syntax">, (</span><span class="identifier-syntax">the</span><span class="plain-syntax">) </span><span class="identifier-syntax">F</span><span class="plain-syntax">, </span><span class="string-syntax">" to "</span><span class="plain-syntax">, (</span><span class="identifier-syntax">the</span><span class="plain-syntax">) </span><span class="identifier-syntax">T</span><span class="plain-syntax">, </span><span class="string-syntax">".^"</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">F</span><span class="plain-syntax"> </span><span class="reserved-syntax">has</span><span class="plain-syntax"> </span><span class="identifier-syntax">worn</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">give</span><span class="plain-syntax"> </span><span class="identifier-syntax">F</span><span class="plain-syntax"> ~</span><span class="identifier-syntax">worn</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">F</span><span class="plain-syntax"> </span><span class="reserved-syntax">in</span><span class="plain-syntax"> </span><span class="identifier-syntax">T</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">DetachPart</span><span class="plain-syntax">(</span><span class="identifier-syntax">F</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">going_mode</span><span class="plain-syntax"> == </span><span class="reserved-syntax">false</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">F</span><span class="plain-syntax"> == </span><span class="identifier-syntax">player</span><span class="plain-syntax">) { </span><span class="identifier-syntax">PlayerTo</span><span class="plain-syntax">(</span><span class="identifier-syntax">T</span><span class="plain-syntax">, </span><span class="identifier-syntax">opt</span><span class="plain-syntax">); </span><span class="reserved-syntax">return</span><span class="plain-syntax">; }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">IndirectlyContains</span><span class="plain-syntax">(</span><span class="identifier-syntax">F</span><span class="plain-syntax">, </span><span class="identifier-syntax">player</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">L</span><span class="plain-syntax"> = </span><span class="identifier-syntax">LocationOf</span><span class="plain-syntax">(</span><span class="identifier-syntax">T</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">L</span><span class="plain-syntax"> == </span><span class="reserved-syntax">nothing</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">IssueMovedPlayerOffStage</span><span class="plain-syntax">();</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">LocationOf</span><span class="plain-syntax">(</span><span class="identifier-syntax">player</span><span class="plain-syntax">) ~= </span><span class="identifier-syntax">L</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">was</span><span class="plain-syntax"> = </span><span class="reserved-syntax">parent</span><span class="plain-syntax">(</span><span class="identifier-syntax">player</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">move</span><span class="plain-syntax"> </span><span class="identifier-syntax">player</span><span class="plain-syntax"> </span><span class="reserved-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">real_location</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">move</span><span class="plain-syntax"> </span><span class="identifier-syntax">F</span><span class="plain-syntax"> </span><span class="reserved-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">T</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">PlayerTo</span><span class="plain-syntax">(</span><span class="identifier-syntax">was</span><span class="plain-syntax">, </span><span class="reserved-syntax">true</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">move</span><span class="plain-syntax"> </span><span class="identifier-syntax">F</span><span class="plain-syntax"> </span><span class="reserved-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">T</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">IssueBackdropOnlyRTP</span><span class="plain-syntax"> </span><span class="identifier-syntax">obj</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">IssueRTP</span><span class="plain-syntax">(</span><span class="string-syntax">"NonBackdropMovedToMultipleRooms"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="string-syntax">"Only backdrops can be moved to multiple rooms or regions."</span><span class="plain-syntax">, </span><span class="identifier-syntax">WorldModelKitRTPs</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="string-syntax">"*** "</span><span class="plain-syntax">, (</span><span class="identifier-syntax">The</span><span class="plain-syntax">) </span><span class="identifier-syntax">obj</span><span class="plain-syntax">, </span><span class="string-syntax">" is not a backdrop.^"</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">RemoveFromPlay</span><span class="plain-syntax"> </span><span class="identifier-syntax">F</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">F</span><span class="plain-syntax"> == </span><span class="reserved-syntax">nothing</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">IssueRTP</span><span class="plain-syntax">(</span><span class="string-syntax">"NothingRemoved"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="string-syntax">"You can't remove nothing from play."</span><span class="plain-syntax">, </span><span class="identifier-syntax">WorldModelKitRTPs</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">F</span><span class="plain-syntax"> == </span><span class="identifier-syntax">player</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">IssueRTP</span><span class="plain-syntax">(</span><span class="string-syntax">"RemovedPlayerFromPlay"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="string-syntax">"You can't remove the player from play."</span><span class="plain-syntax">, </span><span class="identifier-syntax">WorldModelKitRTPs</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">F</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K4_door</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">IssueRTP</span><span class="plain-syntax">(</span><span class="string-syntax">"RemovedDoorFromPlay"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="string-syntax">"You can't remove a door from play."</span><span class="plain-syntax">, </span><span class="identifier-syntax">WorldModelKitRTPs</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">F</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K1_room</span><span class="plain-syntax">) { </span><span class="identifier-syntax">SetRegionalContainment</span><span class="plain-syntax">(</span><span class="identifier-syntax">F</span><span class="plain-syntax">, </span><span class="reserved-syntax">nothing</span><span class="plain-syntax">); </span><span class="reserved-syntax">return</span><span class="plain-syntax">; }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">IndirectlyContains</span><span class="plain-syntax">(</span><span class="identifier-syntax">F</span><span class="plain-syntax">, </span><span class="identifier-syntax">player</span><span class="plain-syntax">)) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">IssueMovedPlayerOffStage</span><span class="plain-syntax">();</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">give</span><span class="plain-syntax"> </span><span class="identifier-syntax">F</span><span class="plain-syntax"> ~</span><span class="identifier-syntax">worn</span><span class="plain-syntax">; </span><span class="identifier-syntax">DetachPart</span><span class="plain-syntax">(</span><span class="identifier-syntax">F</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">F</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K7_backdrop</span><span class="plain-syntax">) </span><span class="reserved-syntax">give</span><span class="plain-syntax"> </span><span class="identifier-syntax">F</span><span class="plain-syntax"> </span><span class="identifier-syntax">absent</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">remove</span><span class="plain-syntax"> </span><span class="identifier-syntax">F</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">IssueMovedPlayerOffStage</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">IssueRTP</span><span class="plain-syntax">(</span><span class="string-syntax">"MovedPlayerOffStage"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="string-syntax">"You can't move the player off-stage."</span><span class="plain-syntax">, </span><span class="identifier-syntax">WorldModelKitRTPs</span><span class="plain-syntax">);</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP12" class="paragraph-anchor"></a><b>&#167;12. On Stage.</b>The following implements the "on-stage" and "off-stage" adjectives
provided by the Standard Rules. Here, as above, note that the I6 attribute
<span class="extract"><span class="extract-syntax">absent</span></span> marks a floating object (see below) which has been removed from
play; in I7 only doors and backdrops are allowed to float, and only backdrops
are allowed to be removed from play.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">OnStage</span><span class="plain-syntax"> </span><span class="identifier-syntax">O</span><span class="plain-syntax"> </span><span class="identifier-syntax">set</span><span class="plain-syntax"> </span><span class="identifier-syntax">x</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">O</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K1_room</span><span class="plain-syntax">) </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">set</span><span class="plain-syntax"> &lt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">while</span><span class="plain-syntax"> (</span><span class="reserved-syntax">metaclass</span><span class="plain-syntax">(</span><span class="identifier-syntax">O</span><span class="plain-syntax">) == </span><span class="identifier-syntax">Object</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">O</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K1_room</span><span class="plain-syntax">) </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">O</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K9_region</span><span class="plain-syntax">) </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">O</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K4_door</span><span class="plain-syntax">) </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">O</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K7_backdrop</span><span class="plain-syntax">) { </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">O</span><span class="plain-syntax"> </span><span class="reserved-syntax">has</span><span class="plain-syntax"> </span><span class="identifier-syntax">absent</span><span class="plain-syntax">) </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">; </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">; }</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">x</span><span class="plain-syntax"> = </span><span class="identifier-syntax">O</span><span class="plain-syntax">.</span><span class="identifier-syntax">component_parent</span><span class="plain-syntax">; </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">x</span><span class="plain-syntax">) { </span><span class="identifier-syntax">O</span><span class="plain-syntax"> = </span><span class="identifier-syntax">x</span><span class="plain-syntax">; </span><span class="reserved-syntax">continue</span><span class="plain-syntax">; }</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">x</span><span class="plain-syntax"> = </span><span class="reserved-syntax">parent</span><span class="plain-syntax">(</span><span class="identifier-syntax">O</span><span class="plain-syntax">); </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">x</span><span class="plain-syntax">) { </span><span class="identifier-syntax">O</span><span class="plain-syntax"> = </span><span class="identifier-syntax">x</span><span class="plain-syntax">; </span><span class="reserved-syntax">continue</span><span class="plain-syntax">; }</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">x</span><span class="plain-syntax"> = </span><span class="identifier-syntax">OnStage</span><span class="plain-syntax">(</span><span class="identifier-syntax">O</span><span class="plain-syntax">, -1);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">x</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">set</span><span class="plain-syntax"> == </span><span class="reserved-syntax">false</span><span class="plain-syntax">)) </span><span class="identifier-syntax">RemoveFromPlay</span><span class="plain-syntax">(</span><span class="identifier-syntax">O</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">x</span><span class="plain-syntax"> == </span><span class="reserved-syntax">false</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">set</span><span class="plain-syntax">)) </span><span class="identifier-syntax">MoveObject</span><span class="plain-syntax">(</span><span class="identifier-syntax">O</span><span class="plain-syntax">, </span><span class="identifier-syntax">real_location</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP13" class="paragraph-anchor"></a><b>&#167;13. Moving the Player.</b>Note that the player object can only be moved by this routine: this allows
us to maintain the invariant for <span class="extract"><span class="extract-syntax">real_location</span></span> and <span class="extract"><span class="extract-syntax">location</span></span> (for which,
see "Light.i6t") and to ensure that multiply-present objects can be
witnessed where they need to be.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">PlayerTo</span><span class="plain-syntax"> </span><span class="identifier-syntax">newplace</span><span class="plain-syntax"> </span><span class="identifier-syntax">flag</span><span class="plain-syntax"> </span><span class="identifier-syntax">L</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">L</span><span class="plain-syntax"> = </span><span class="identifier-syntax">LocationOf</span><span class="plain-syntax">(</span><span class="identifier-syntax">newplace</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">L</span><span class="plain-syntax"> == </span><span class="reserved-syntax">nothing</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">IssueMovedPlayerOffStage</span><span class="plain-syntax">();</span>
<span class="plain-syntax">    @</span><span class="identifier-syntax">push</span><span class="plain-syntax"> </span><span class="identifier-syntax">actor</span><span class="plain-syntax">; </span><span class="identifier-syntax">actor</span><span class="plain-syntax"> = </span><span class="identifier-syntax">player</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">move</span><span class="plain-syntax"> </span><span class="identifier-syntax">player</span><span class="plain-syntax"> </span><span class="reserved-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">newplace</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">location</span><span class="plain-syntax"> = </span><span class="identifier-syntax">L</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">real_location</span><span class="plain-syntax"> = </span><span class="identifier-syntax">location</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">MoveFloatingObjects</span><span class="plain-syntax">();</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">SilentlyConsiderLight</span><span class="plain-syntax">();</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">DivideParagraphPoint</span><span class="plain-syntax">();</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">flag</span><span class="plain-syntax"> == </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="identifier-syntax">R_Process</span><span class="plain-syntax">(##</span><span class="identifier-syntax">Look</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">flag</span><span class="plain-syntax"> == </span><span class="constant-syntax">1</span><span class="plain-syntax">) </span><span class="reserved-syntax">give</span><span class="plain-syntax"> </span><span class="identifier-syntax">location</span><span class="plain-syntax"> </span><span class="identifier-syntax">visited</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">flag</span><span class="plain-syntax"> == </span><span class="constant-syntax">2</span><span class="plain-syntax">) </span><span class="identifier-syntax">AbbreviatedRoomDescription</span><span class="plain-syntax">();</span>
<span class="plain-syntax">    @</span><span class="identifier-syntax">pull</span><span class="plain-syntax"> </span><span class="identifier-syntax">actor</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP14" class="paragraph-anchor"></a><b>&#167;14. Move During Going.</b>The following routine preserves the invariant for <span class="extract"><span class="extract-syntax">real_location</span></span>, but gets
<span class="extract"><span class="extract-syntax">location</span></span> wrong since it doesn't adjust for light. Nor are floating objects
moved. It should be used only in the course of other operations which get
the rest of this right. (I7 uses it only for the "going" action, where
these various operations are each handled by different named rules to
increase the flexibility of the system.)
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">MoveDuringGoing</span><span class="plain-syntax"> </span><span class="identifier-syntax">F</span><span class="plain-syntax"> </span><span class="identifier-syntax">T</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">MoveObject</span><span class="plain-syntax">(</span><span class="identifier-syntax">F</span><span class="plain-syntax">, </span><span class="identifier-syntax">T</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">, </span><span class="reserved-syntax">true</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">actor</span><span class="plain-syntax"> == </span><span class="identifier-syntax">player</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">location</span><span class="plain-syntax"> = </span><span class="identifier-syntax">LocationOf</span><span class="plain-syntax">(</span><span class="identifier-syntax">player</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">real_location</span><span class="plain-syntax"> = </span><span class="identifier-syntax">location</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP15" class="paragraph-anchor"></a><b>&#167;15. Being Everywhere.</b>The following is used as the <span class="extract"><span class="extract-syntax">found_in</span></span> property for any backdrop which is
"everywhere", that is, which is found in every room.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">FoundEverywhere</span><span class="plain-syntax">; </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">; ];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP16" class="paragraph-anchor"></a><b>&#167;16. Testing Everywhere.</b></p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">BackdropEverywhere</span><span class="plain-syntax"> </span><span class="identifier-syntax">O</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">O</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K7_backdrop</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">O</span><span class="plain-syntax"> </span><span class="reserved-syntax">has</span><span class="plain-syntax"> </span><span class="identifier-syntax">absent</span><span class="plain-syntax">) </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">O</span><span class="plain-syntax">.</span><span class="identifier-syntax">found_in</span><span class="plain-syntax"> == </span><span class="identifier-syntax">FoundEverywhere</span><span class="plain-syntax">) </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP17" class="paragraph-anchor"></a><b>&#167;17. Changing the Player.</b>It is very important that nobody simply change the value of the <span class="extract"><span class="extract-syntax">player</span></span>
variable, because so much else must be updated when the identity of the
player changes: the light situation, floating objects, the <span class="extract"><span class="extract-syntax">real_location</span></span>
and so on. Because of this, the Inform compiler contains code which compiles
an assertion of the proposition "is(<span class="extract"><span class="extract-syntax">player</span></span>, \(X\))" into a function call
<span class="extract"><span class="extract-syntax">ChangePlayer(X)</span></span> rather than a variable assignment <span class="extract"><span class="extract-syntax">player = X</span></span>. So we
cannot catch out the system by writing "now the player is Mr Henderson".
</p>

<p class="commentary">We must ensure that if <span class="extract"><span class="extract-syntax">player</span></span> is initially X, is changed to Y, and is then
changed back to X, that both X and Y end exactly as they began &mdash; hence the
flummery below with using <span class="extract"><span class="extract-syntax">remove_proper</span></span> to ensure that <span class="extract"><span class="extract-syntax">proper</span></span> is left
with the correct value. Note that:
</p>

<ul class="items"><li>(1) at any given time exactly one person has the I6 <span class="extract"><span class="extract-syntax">concealed</span></span> attribute: the
current player;
</li><li>(2) the <span class="extract"><span class="extract-syntax">selfobj</span></span> is the default initial value of <span class="extract"><span class="extract-syntax">player</span></span>, and because it has
as its actual printed name "yourself", we need to override this when
something else takes over as player: we change to "your former self", in
fact. No such device is needed for other people being changed from because
they are explicitly given printed names &mdash; say "Mr Darcy", "the sous-chef",
etc. &mdash; in the source text.
</li></ul>
<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">ChangePlayer</span><span class="plain-syntax"> </span><span class="identifier-syntax">obj</span><span class="plain-syntax"> </span><span class="identifier-syntax">flag</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (~~(</span><span class="identifier-syntax">obj</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K8_person</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">IssueRTP</span><span class="plain-syntax">(</span><span class="string-syntax">"ChangedPlayerToNonPerson"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="string-syntax">"A player can only be changed to a person."</span><span class="plain-syntax">, </span><span class="identifier-syntax">WorldModelKitRTPs</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="string-syntax">"*** Tried to change player to "</span><span class="plain-syntax">, (</span><span class="identifier-syntax">the</span><span class="plain-syntax">) </span><span class="identifier-syntax">obj</span><span class="plain-syntax">, </span><span class="string-syntax">", which is not a person.^"</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (~~(</span><span class="identifier-syntax">OnStage</span><span class="plain-syntax">(</span><span class="identifier-syntax">obj</span><span class="plain-syntax">, -1))) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">IssueRTP</span><span class="plain-syntax">(</span><span class="string-syntax">"ChangedPlayerToOffStagePerson"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="string-syntax">"Attempt to change the player to a person off-stage."</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">WorldModelKitRTPs</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="string-syntax">"*** "</span><span class="plain-syntax">, (</span><span class="identifier-syntax">The</span><span class="plain-syntax">) </span><span class="identifier-syntax">obj</span><span class="plain-syntax">, </span><span class="string-syntax">" is currently off-stage.^"</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">obj</span><span class="plain-syntax">.</span><span class="identifier-syntax">component_parent</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">IssueMadePlayerPartOfSomething</span><span class="plain-syntax">(</span><span class="identifier-syntax">obj</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">obj</span><span class="plain-syntax"> == </span><span class="identifier-syntax">player</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">give</span><span class="plain-syntax"> </span><span class="identifier-syntax">player</span><span class="plain-syntax"> ~</span><span class="identifier-syntax">concealed</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">player</span><span class="plain-syntax"> </span><span class="reserved-syntax">has</span><span class="plain-syntax"> </span><span class="identifier-syntax">remove_proper</span><span class="plain-syntax">) </span><span class="reserved-syntax">give</span><span class="plain-syntax"> </span><span class="identifier-syntax">player</span><span class="plain-syntax"> ~</span><span class="identifier-syntax">proper</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">player</span><span class="plain-syntax"> == </span><span class="identifier-syntax">selfobj</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">player</span><span class="plain-syntax">.</span><span class="identifier-syntax">saved_short_name</span><span class="plain-syntax"> = </span><span class="identifier-syntax">player</span><span class="plain-syntax">.</span><span class="identifier-syntax">short_name</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">player</span><span class="plain-syntax">.</span><span class="identifier-syntax">short_name</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PRINT_PROTAGONIST_INTERNAL_RM</span><span class="plain-syntax">(</span><span class="character-syntax">'c'</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">player</span><span class="plain-syntax"> = </span><span class="identifier-syntax">obj</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">player</span><span class="plain-syntax"> == </span><span class="identifier-syntax">selfobj</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">player</span><span class="plain-syntax">.</span><span class="identifier-syntax">short_name</span><span class="plain-syntax"> = </span><span class="identifier-syntax">player</span><span class="plain-syntax">.</span><span class="identifier-syntax">saved_short_name</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">player</span><span class="plain-syntax"> </span><span class="reserved-syntax">hasnt</span><span class="plain-syntax"> </span><span class="identifier-syntax">proper</span><span class="plain-syntax">) </span><span class="reserved-syntax">give</span><span class="plain-syntax"> </span><span class="identifier-syntax">player</span><span class="plain-syntax"> </span><span class="identifier-syntax">remove_proper</span><span class="plain-syntax">; </span><span class="comment-syntax">when changing out again</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">give</span><span class="plain-syntax"> </span><span class="identifier-syntax">player</span><span class="plain-syntax"> </span><span class="identifier-syntax">concealed</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">give</span><span class="plain-syntax"> </span><span class="identifier-syntax">player</span><span class="plain-syntax"> </span><span class="identifier-syntax">proper</span><span class="plain-syntax">;</span>

<span class="plain-syntax">    </span><span class="identifier-syntax">location</span><span class="plain-syntax"> = </span><span class="identifier-syntax">LocationOf</span><span class="plain-syntax">(</span><span class="identifier-syntax">player</span><span class="plain-syntax">); </span><span class="identifier-syntax">real_location</span><span class="plain-syntax"> = </span><span class="identifier-syntax">location</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">MoveFloatingObjects</span><span class="plain-syntax">();</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">SilentlyConsiderLight</span><span class="plain-syntax">();</span>
<span class="plain-syntax">];</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">IssueMadePlayerPartOfSomething</span><span class="plain-syntax"> </span><span class="identifier-syntax">obj</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">IssueRTP</span><span class="plain-syntax">(</span><span class="string-syntax">"MadePlayerPartOfSomething"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="string-syntax">"Tried to make the player part of something."</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WorldModelKitRTPs</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="string-syntax">"*** Tried to make the player part of "</span><span class="plain-syntax">, (</span><span class="identifier-syntax">the</span><span class="plain-syntax">) </span><span class="identifier-syntax">obj</span><span class="plain-syntax">, </span><span class="string-syntax">".^"</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP18" class="paragraph-anchor"></a><b>&#167;18. Floating Objects.</b>A single object can only be in one position in the object tree, yet backdrops
and doors must be present in multiple rooms. This is accomplished by making
them, in I6 jargon, "floating objects": objects which move in the tree
whenever the player does, so that &mdash; from the player's perspective &mdash; they
are always present when they should be. In I6, almost anything can be made
a floating object, but in I7 this is strictly and only used for backdrops
and two-sided doors.
</p>

<p class="commentary">There are several conceptual problems with this scheme: chiefly that it
assumes that the only witness to the spatial arrangement of objects is the
player. In I6 that was usually true, but in I7, where every person can
undertake actions, it really isn't true any longer: if the objects float
to follow the player, it means that they are not present with other people
who might need to interact with them. This is why the accessibility rules
are somewhat hacked for backdrops and doors (see "Light.i6t"). In fact we
generally achieve the illusion we want, but this is largely because it is
difficult to catch out all the exceptions for backdrops and doors, and
because in practice authors tend not to set things up so that the presence
or absence of backdrops much affects what non-player characters do.
</p>

<p class="commentary">All the same, the scheme is not logically defensible, and this is why we
do not allow the user to create new categories of floating objects in I7.
</p>

<p class="commentary">The I6 implementation of <span class="extract"><span class="extract-syntax">MoveFloatingObjects</span></span> acted on the <span class="extract"><span class="extract-syntax">location</span></span>
rather than the <span class="extract"><span class="extract-syntax">real_location</span></span>, which (a) meant that multiply-present objects
could include <span class="extract"><span class="extract-syntax">thedark</span></span> &mdash; the generic Darkness place &mdash; as one possible
location, but (b) assumed that the only sense by which the player could
witness an object was sight. In I7, <span class="extract"><span class="extract-syntax">thedark</span></span> is not a valid room, and we
are a bit more careful about the senses.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">MoveFloatingObjects</span><span class="plain-syntax"> </span><span class="identifier-syntax">toroom</span><span class="plain-syntax"> </span><span class="identifier-syntax">i</span><span class="plain-syntax"> </span><span class="identifier-syntax">k</span><span class="plain-syntax"> </span><span class="identifier-syntax">l</span><span class="plain-syntax"> </span><span class="identifier-syntax">m</span><span class="plain-syntax"> </span><span class="identifier-syntax">address</span><span class="plain-syntax"> </span><span class="identifier-syntax">flag</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">toroom</span><span class="plain-syntax"> == </span><span class="reserved-syntax">nothing</span><span class="plain-syntax">) </span><span class="identifier-syntax">toroom</span><span class="plain-syntax"> = </span><span class="identifier-syntax">real_location</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">toroom</span><span class="plain-syntax"> == </span><span class="reserved-syntax">nothing</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">objectloop</span><span class="plain-syntax"> (</span><span class="identifier-syntax">i</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">address</span><span class="plain-syntax"> = </span><span class="identifier-syntax">i</span><span class="plain-syntax">.&amp;</span><span class="identifier-syntax">found_in</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">address</span><span class="plain-syntax"> ~= </span><span class="constant-syntax">0</span><span class="plain-syntax"> &amp;&amp; </span><span class="identifier-syntax">i</span><span class="plain-syntax"> </span><span class="reserved-syntax">hasnt</span><span class="plain-syntax"> </span><span class="identifier-syntax">absent</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ZRegion</span><span class="plain-syntax">(</span><span class="identifier-syntax">address</span><span class="plain-syntax">--&gt;0) == </span><span class="constant-syntax">2</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">m</span><span class="plain-syntax"> = </span><span class="identifier-syntax">address</span><span class="plain-syntax">--&gt;0;</span>
<span class="plain-syntax">                .</span><span class="identifier-syntax">TestPropositionally</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">m</span><span class="plain-syntax">.</span><span class="identifier-syntax">call</span><span class="plain-syntax">(</span><span class="identifier-syntax">toroom</span><span class="plain-syntax">) ~= </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">move</span><span class="plain-syntax"> </span><span class="identifier-syntax">i</span><span class="plain-syntax"> </span><span class="reserved-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">toroom</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">else</span><span class="plain-syntax"> { </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">i</span><span class="plain-syntax"> </span><span class="reserved-syntax">in</span><span class="plain-syntax"> </span><span class="identifier-syntax">toroom</span><span class="plain-syntax">) </span><span class="reserved-syntax">remove</span><span class="plain-syntax"> </span><span class="identifier-syntax">i</span><span class="plain-syntax">; }</span>
<span class="plain-syntax">            } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">k</span><span class="plain-syntax"> = </span><span class="identifier-syntax">i</span><span class="plain-syntax">.#</span><span class="identifier-syntax">found_in</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">l</span><span class="plain-syntax">=0 : </span><span class="identifier-syntax">l</span><span class="plain-syntax">&lt;</span><span class="identifier-syntax">k</span><span class="plain-syntax">/</span><span class="identifier-syntax">WORDSIZE</span><span class="plain-syntax"> : </span><span class="identifier-syntax">l</span><span class="plain-syntax">++) {</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">m</span><span class="plain-syntax"> = </span><span class="identifier-syntax">address</span><span class="plain-syntax">--&gt;</span><span class="identifier-syntax">l</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ZRegion</span><span class="plain-syntax">(</span><span class="identifier-syntax">m</span><span class="plain-syntax">) == </span><span class="constant-syntax">2</span><span class="plain-syntax">) </span><span class="reserved-syntax">jump</span><span class="plain-syntax"> </span><span class="identifier-syntax">TestPropositionally</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">m</span><span class="plain-syntax"> == </span><span class="identifier-syntax">toroom</span><span class="plain-syntax"> || </span><span class="identifier-syntax">m</span><span class="plain-syntax"> </span><span class="reserved-syntax">in</span><span class="plain-syntax"> </span><span class="identifier-syntax">toroom</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">i</span><span class="plain-syntax"> </span><span class="reserved-syntax">notin</span><span class="plain-syntax"> </span><span class="identifier-syntax">toroom</span><span class="plain-syntax">) </span><span class="reserved-syntax">move</span><span class="plain-syntax"> </span><span class="identifier-syntax">i</span><span class="plain-syntax"> </span><span class="reserved-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">toroom</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                        </span><span class="identifier-syntax">flag</span><span class="plain-syntax"> = </span><span class="reserved-syntax">true</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                    }</span>
<span class="plain-syntax">                }</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">flag</span><span class="plain-syntax"> == </span><span class="reserved-syntax">false</span><span class="plain-syntax">) { </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">i</span><span class="plain-syntax"> </span><span class="reserved-syntax">in</span><span class="plain-syntax"> </span><span class="identifier-syntax">toroom</span><span class="plain-syntax">) </span><span class="reserved-syntax">remove</span><span class="plain-syntax"> </span><span class="identifier-syntax">i</span><span class="plain-syntax">; }</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">i</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K4_door</span><span class="plain-syntax">) &amp;&amp; (</span><span class="reserved-syntax">parent</span><span class="plain-syntax">(</span><span class="identifier-syntax">i</span><span class="plain-syntax">) == </span><span class="reserved-syntax">nothing</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">move</span><span class="plain-syntax"> </span><span class="identifier-syntax">i</span><span class="plain-syntax"> </span><span class="reserved-syntax">to</span><span class="plain-syntax"> (</span><span class="identifier-syntax">i</span><span class="plain-syntax">.</span><span class="identifier-syntax">door_to</span><span class="plain-syntax">());</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">];</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">MoveBackdrop</span><span class="plain-syntax"> </span><span class="identifier-syntax">bd</span><span class="plain-syntax"> </span><span class="identifier-syntax">D</span><span class="plain-syntax"> </span><span class="identifier-syntax">x</span><span class="plain-syntax"> </span><span class="identifier-syntax">address</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (~~(</span><span class="identifier-syntax">bd</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K7_backdrop</span><span class="plain-syntax">)) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">IssueBackdropOnlyRTP</span><span class="plain-syntax">(</span><span class="identifier-syntax">bd</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">bd</span><span class="plain-syntax">.#</span><span class="identifier-syntax">found_in</span><span class="plain-syntax"> &gt; </span><span class="identifier-syntax">WORDSIZE</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">address</span><span class="plain-syntax"> = </span><span class="identifier-syntax">bd</span><span class="plain-syntax">.&amp;</span><span class="identifier-syntax">found_in</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">address</span><span class="plain-syntax">--&gt;0 = </span><span class="identifier-syntax">D</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="identifier-syntax">bd</span><span class="plain-syntax">.</span><span class="identifier-syntax">found_in</span><span class="plain-syntax"> = </span><span class="identifier-syntax">D</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">give</span><span class="plain-syntax"> </span><span class="identifier-syntax">bd</span><span class="plain-syntax"> ~</span><span class="identifier-syntax">absent</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">MoveFloatingObjects</span><span class="plain-syntax">();</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP19" class="paragraph-anchor"></a><b>&#167;19. Backdrop Location.</b>This determines what the "location" of a backdrop is, or, if "target" is
other than nothing, determines whether it can ever be the location. Note
that this routine also works for two-sided doors, despite its name.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">BackdropLocation</span><span class="plain-syntax"> </span><span class="identifier-syntax">O</span><span class="plain-syntax"> </span><span class="identifier-syntax">target</span><span class="plain-syntax"> </span><span class="identifier-syntax">address</span><span class="plain-syntax"> </span><span class="identifier-syntax">m</span><span class="plain-syntax"> </span><span class="identifier-syntax">x</span><span class="plain-syntax"> </span><span class="identifier-syntax">i</span><span class="plain-syntax"> </span><span class="identifier-syntax">k</span><span class="plain-syntax"> </span><span class="identifier-syntax">l</span><span class="plain-syntax"> </span><span class="identifier-syntax">r</span><span class="plain-syntax"> </span><span class="identifier-syntax">sl</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">O</span><span class="plain-syntax"> </span><span class="reserved-syntax">has</span><span class="plain-syntax"> </span><span class="identifier-syntax">absent</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="reserved-syntax">nothing</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">target</span><span class="plain-syntax"> == </span><span class="reserved-syntax">nothing</span><span class="plain-syntax"> </span><span class="reserved-syntax">or</span><span class="plain-syntax"> </span><span class="identifier-syntax">real_location</span><span class="plain-syntax">) &amp;&amp; (</span><span class="reserved-syntax">parent</span><span class="plain-syntax">(</span><span class="identifier-syntax">O</span><span class="plain-syntax">) == </span><span class="identifier-syntax">real_location</span><span class="plain-syntax">))</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">real_location</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">address</span><span class="plain-syntax"> = </span><span class="identifier-syntax">O</span><span class="plain-syntax">.&amp;</span><span class="identifier-syntax">found_in</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">address</span><span class="plain-syntax"> ~= </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">k</span><span class="plain-syntax"> = </span><span class="identifier-syntax">O</span><span class="plain-syntax">.#</span><span class="identifier-syntax">found_in</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">l</span><span class="plain-syntax">=0 : </span><span class="identifier-syntax">l</span><span class="plain-syntax">&lt;</span><span class="identifier-syntax">k</span><span class="plain-syntax">/</span><span class="identifier-syntax">WORDSIZE</span><span class="plain-syntax"> : </span><span class="identifier-syntax">l</span><span class="plain-syntax">++) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">m</span><span class="plain-syntax"> = </span><span class="identifier-syntax">address</span><span class="plain-syntax">--&gt;</span><span class="identifier-syntax">l</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ZRegion</span><span class="plain-syntax">(</span><span class="identifier-syntax">m</span><span class="plain-syntax">) == </span><span class="constant-syntax">2</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">sl</span><span class="plain-syntax"> = </span><span class="identifier-syntax">location</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">target</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">location</span><span class="plain-syntax"> = </span><span class="identifier-syntax">target</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">r</span><span class="plain-syntax"> = </span><span class="identifier-syntax">m</span><span class="plain-syntax">.</span><span class="identifier-syntax">call</span><span class="plain-syntax">();</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">r</span><span class="plain-syntax"> ~= </span><span class="constant-syntax">0</span><span class="plain-syntax">) { </span><span class="identifier-syntax">location</span><span class="plain-syntax"> = </span><span class="identifier-syntax">sl</span><span class="plain-syntax">; </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">target</span><span class="plain-syntax">; }</span>
<span class="plain-syntax">                } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">objectloop</span><span class="plain-syntax"> (</span><span class="identifier-syntax">x</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K1_room</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                        </span><span class="identifier-syntax">location</span><span class="plain-syntax"> = </span><span class="identifier-syntax">x</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                        </span><span class="identifier-syntax">r</span><span class="plain-syntax"> = </span><span class="identifier-syntax">m</span><span class="plain-syntax">.</span><span class="identifier-syntax">call</span><span class="plain-syntax">();</span>
<span class="plain-syntax">                        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">r</span><span class="plain-syntax"> ~= </span><span class="constant-syntax">0</span><span class="plain-syntax">) { </span><span class="identifier-syntax">location</span><span class="plain-syntax"> = </span><span class="identifier-syntax">sl</span><span class="plain-syntax">; </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">x</span><span class="plain-syntax">; }</span>
<span class="plain-syntax">                    }</span>
<span class="plain-syntax">                }</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">location</span><span class="plain-syntax"> = </span><span class="identifier-syntax">sl</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">m</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K9_region</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">objectloop</span><span class="plain-syntax"> (</span><span class="identifier-syntax">x</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K1_room</span><span class="plain-syntax">)</span>
<span class="plain-syntax">                        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">TestRegionalContainment</span><span class="plain-syntax">(</span><span class="identifier-syntax">x</span><span class="plain-syntax">, </span><span class="identifier-syntax">m</span><span class="plain-syntax">))</span>
<span class="plain-syntax">                            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">target</span><span class="plain-syntax"> == </span><span class="reserved-syntax">nothing</span><span class="plain-syntax"> </span><span class="reserved-syntax">or</span><span class="plain-syntax"> </span><span class="identifier-syntax">x</span><span class="plain-syntax">)</span>
<span class="plain-syntax">                                </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">x</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">target</span><span class="plain-syntax"> == </span><span class="reserved-syntax">nothing</span><span class="plain-syntax"> </span><span class="reserved-syntax">or</span><span class="plain-syntax"> </span><span class="identifier-syntax">m</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">m</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                }</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="reserved-syntax">nothing</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP20" class="paragraph-anchor"></a><b>&#167;20. Map Connections.</b><span class="extract"><span class="extract-syntax">MapConnection</span></span> returns the room which is in the given direction (as an object)
from the given room: it is used, among other things, to test the "mapped east
of" and similar relations. (The same relations are asserted true with
<span class="extract"><span class="extract-syntax">AssertMapConnection</span></span> and false with <span class="extract"><span class="extract-syntax">AssertMapUnconnection</span></span>.)
</p>

<p class="commentary"><span class="extract"><span class="extract-syntax">RoomOrDoorFrom</span></span> returns either the room or door which is in the given
direction, and is thus simpler (since it doesn't have to investigate what
is through such a door).
</p>

<p class="commentary">Both routines return values which are type-safe in I7 provided the kind of
value they are assigned to is "object": neither returns any specific kind
of object without fail. (<span class="extract"><span class="extract-syntax">MapConnection</span></span> is always either a door or <span class="extract"><span class="extract-syntax">nothing</span></span>,
but <span class="extract"><span class="extract-syntax">nothing</span></span> is not a typesafe value for "door".)
</p>

<p class="commentary">Note that map connections via doors are immutable.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">MapConnection</span><span class="plain-syntax"> </span><span class="identifier-syntax">from_room</span><span class="plain-syntax"> </span><span class="identifier-syntax">dir</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">in_direction</span><span class="plain-syntax"> </span><span class="identifier-syntax">through_door</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">from_room</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K1_room</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">dir</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K3_direction</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">in_direction</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Map_Storage</span><span class="plain-syntax">--&gt;</span>
<span class="plain-syntax">            ((</span><span class="identifier-syntax">from_room</span><span class="plain-syntax">.</span><span class="identifier-syntax">IK1_Count</span><span class="plain-syntax">)*</span><span class="identifier-syntax">No_Directions</span><span class="plain-syntax"> + </span><span class="identifier-syntax">dir</span><span class="plain-syntax">.</span><span class="identifier-syntax">IK3_Count</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">in_direction</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K1_room</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">in_direction</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">in_direction</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K4_door</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            @</span><span class="identifier-syntax">push</span><span class="plain-syntax"> </span><span class="identifier-syntax">location</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">location</span><span class="plain-syntax"> = </span><span class="identifier-syntax">from_room</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">through_door</span><span class="plain-syntax"> = </span><span class="identifier-syntax">in_direction</span><span class="plain-syntax">.</span><span class="identifier-syntax">door_to</span><span class="plain-syntax">();</span>
<span class="plain-syntax">            @</span><span class="identifier-syntax">pull</span><span class="plain-syntax"> </span><span class="identifier-syntax">location</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">through_door</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K1_room</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">through_door</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="reserved-syntax">nothing</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">DoorFrom</span><span class="plain-syntax"> </span><span class="identifier-syntax">obj</span><span class="plain-syntax"> </span><span class="identifier-syntax">dir</span><span class="plain-syntax"> </span><span class="identifier-syntax">rv</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">rv</span><span class="plain-syntax"> = </span><span class="identifier-syntax">RoomOrDoorFrom</span><span class="plain-syntax">(</span><span class="identifier-syntax">obj</span><span class="plain-syntax">, </span><span class="identifier-syntax">dir</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">rv</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K4_door</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">rv</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="reserved-syntax">nothing</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">RoomOrDoorFrom</span><span class="plain-syntax"> </span><span class="identifier-syntax">obj</span><span class="plain-syntax"> </span><span class="identifier-syntax">dir</span><span class="plain-syntax"> </span><span class="identifier-syntax">use_doors</span><span class="plain-syntax"> </span><span class="identifier-syntax">in_direction</span><span class="plain-syntax"> </span><span class="identifier-syntax">sl</span><span class="plain-syntax"> </span><span class="identifier-syntax">through_door</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">obj</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K1_room</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">dir</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K3_direction</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">in_direction</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Map_Storage</span><span class="plain-syntax">--&gt;</span>
<span class="plain-syntax">            ((</span><span class="identifier-syntax">obj</span><span class="plain-syntax">.</span><span class="identifier-syntax">IK1_Count</span><span class="plain-syntax">)*</span><span class="identifier-syntax">No_Directions</span><span class="plain-syntax"> + </span><span class="identifier-syntax">dir</span><span class="plain-syntax">.</span><span class="identifier-syntax">IK3_Count</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">in_direction</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K1_room</span><span class="plain-syntax"> </span><span class="reserved-syntax">or</span><span class="plain-syntax"> </span><span class="identifier-syntax">K4_door</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">in_direction</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="reserved-syntax">nothing</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">AssertMapConnection</span><span class="plain-syntax"> </span><span class="identifier-syntax">r1</span><span class="plain-syntax"> </span><span class="identifier-syntax">dir</span><span class="plain-syntax"> </span><span class="identifier-syntax">r2</span><span class="plain-syntax"> </span><span class="identifier-syntax">in_direction</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">SignalMapChange</span><span class="plain-syntax">();</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">in_direction</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Map_Storage</span><span class="plain-syntax">--&gt;</span>
<span class="plain-syntax">        ((</span><span class="identifier-syntax">r1</span><span class="plain-syntax">.</span><span class="identifier-syntax">IK1_Count</span><span class="plain-syntax">)*</span><span class="identifier-syntax">No_Directions</span><span class="plain-syntax"> + </span><span class="identifier-syntax">dir</span><span class="plain-syntax">.</span><span class="identifier-syntax">IK3_Count</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">in_direction</span><span class="plain-syntax"> == </span><span class="constant-syntax">0</span><span class="plain-syntax">) || (</span><span class="identifier-syntax">in_direction</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K1_room</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Map_Storage</span><span class="plain-syntax">--&gt;((</span><span class="identifier-syntax">r1</span><span class="plain-syntax">.</span><span class="identifier-syntax">IK1_Count</span><span class="plain-syntax">)*</span><span class="identifier-syntax">No_Directions</span><span class="plain-syntax"> + </span><span class="identifier-syntax">dir</span><span class="plain-syntax">.</span><span class="identifier-syntax">IK3_Count</span><span class="plain-syntax">) = </span><span class="identifier-syntax">r2</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">in_direction</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K4_door</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">IssueDoorMovedRTP</span><span class="plain-syntax">(</span><span class="identifier-syntax">r1</span><span class="plain-syntax">, </span><span class="identifier-syntax">dir</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">IssueRTP</span><span class="plain-syntax">(</span><span class="string-syntax">"CouldNotChangeMapConnection"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="string-syntax">"This map connection could not be changed."</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WorldModelKitRTPs</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="string-syntax">"Tried to change "</span><span class="plain-syntax">, (</span><span class="identifier-syntax">the</span><span class="plain-syntax">) </span><span class="identifier-syntax">dir</span><span class="plain-syntax">, </span><span class="string-syntax">" exit of "</span><span class="plain-syntax">, (</span><span class="identifier-syntax">the</span><span class="plain-syntax">) </span><span class="identifier-syntax">r1</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="string-syntax">", but it didn't seem to have such an exit to change.^"</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">AssertMapUnconnection</span><span class="plain-syntax"> </span><span class="identifier-syntax">r1</span><span class="plain-syntax"> </span><span class="identifier-syntax">dir</span><span class="plain-syntax"> </span><span class="identifier-syntax">r2</span><span class="plain-syntax"> </span><span class="identifier-syntax">in_direction</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">SignalMapChange</span><span class="plain-syntax">();</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">in_direction</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Map_Storage</span><span class="plain-syntax">--&gt;</span>
<span class="plain-syntax">        ((</span><span class="identifier-syntax">r1</span><span class="plain-syntax">.</span><span class="identifier-syntax">IK1_Count</span><span class="plain-syntax">)*</span><span class="identifier-syntax">No_Directions</span><span class="plain-syntax"> + </span><span class="identifier-syntax">dir</span><span class="plain-syntax">.</span><span class="identifier-syntax">IK3_Count</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">r1</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K4_door</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">IssueDoorMovedRTP</span><span class="plain-syntax">(</span><span class="identifier-syntax">r1</span><span class="plain-syntax">, </span><span class="identifier-syntax">dir</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">in_direction</span><span class="plain-syntax"> == </span><span class="identifier-syntax">r2</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Map_Storage</span><span class="plain-syntax">--&gt;((</span><span class="identifier-syntax">r1</span><span class="plain-syntax">.</span><span class="identifier-syntax">IK1_Count</span><span class="plain-syntax">)*</span><span class="identifier-syntax">No_Directions</span><span class="plain-syntax"> + </span><span class="identifier-syntax">dir</span><span class="plain-syntax">.</span><span class="identifier-syntax">IK3_Count</span><span class="plain-syntax">) = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">IssueDoorMovedRTP</span><span class="plain-syntax"> </span><span class="identifier-syntax">room</span><span class="plain-syntax"> </span><span class="identifier-syntax">dir</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">IssueRTP</span><span class="plain-syntax">(</span><span class="string-syntax">"DoorMoved"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="string-syntax">"Map connections to doors cannot be changed."</span><span class="plain-syntax">, </span><span class="identifier-syntax">WorldModelKitRTPs</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP21" class="paragraph-anchor"></a><b>&#167;21. Adjacency Relation.</b>A relation between two rooms which, note, does not see connections through
doors.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">TestAdjacency</span><span class="plain-syntax"> </span><span class="identifier-syntax">R1</span><span class="plain-syntax"> </span><span class="identifier-syntax">R2</span><span class="plain-syntax"> </span><span class="identifier-syntax">i</span><span class="plain-syntax"> </span><span class="identifier-syntax">row</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">R1</span><span class="plain-syntax"> == </span><span class="reserved-syntax">nothing</span><span class="plain-syntax">) || (</span><span class="identifier-syntax">R2</span><span class="plain-syntax"> == </span><span class="reserved-syntax">nothing</span><span class="plain-syntax">)) </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">R1</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K9_region</span><span class="plain-syntax">) { </span><span class="identifier-syntax">IssueTestedAdjacencyRTP</span><span class="plain-syntax">(</span><span class="identifier-syntax">R1</span><span class="plain-syntax">); </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">; }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">R2</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K9_region</span><span class="plain-syntax">) { </span><span class="identifier-syntax">IssueTestedAdjacencyRTP</span><span class="plain-syntax">(</span><span class="identifier-syntax">R2</span><span class="plain-syntax">); </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">; }</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">row</span><span class="plain-syntax"> = (</span><span class="identifier-syntax">R1</span><span class="plain-syntax">.</span><span class="identifier-syntax">IK1_Count</span><span class="plain-syntax">)*</span><span class="identifier-syntax">No_Directions</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">i</span><span class="plain-syntax">=0: </span><span class="identifier-syntax">i</span><span class="plain-syntax">&lt;</span><span class="identifier-syntax">No_Directions</span><span class="plain-syntax">: </span><span class="identifier-syntax">i</span><span class="plain-syntax">++, </span><span class="identifier-syntax">row</span><span class="plain-syntax">++)</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Map_Storage</span><span class="plain-syntax">--&gt;</span><span class="identifier-syntax">row</span><span class="plain-syntax"> == </span><span class="identifier-syntax">R2</span><span class="plain-syntax">) </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">IssueTestedAdjacencyRTP</span><span class="plain-syntax"> </span><span class="identifier-syntax">region</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">IssueRTP</span><span class="plain-syntax">(</span><span class="string-syntax">"TestedAdjacencyToRegion"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="string-syntax">"You can't test whether something is adjacent to a region."</span><span class="plain-syntax">, </span><span class="identifier-syntax">WorldModelKitRTPs</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="string-syntax">"*** The region you tried this with was "</span><span class="plain-syntax">, (</span><span class="identifier-syntax">the</span><span class="plain-syntax">) </span><span class="identifier-syntax">region</span><span class="plain-syntax">, </span><span class="string-syntax">".^"</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP22" class="paragraph-anchor"></a><b>&#167;22. Regional Containment Relation.</b>This tests whether an object with a definite physical location is in a
given region. (For a two-sided door which straddles regions, the front side
is what counts; for a backdrop, a direction or another region, the answer
is always no.) We rely on the fact that every room object has a <span class="extract"><span class="extract-syntax">map_region</span></span>
property which is the smallest region containing it, if any does, and
<span class="extract"><span class="extract-syntax">nothing</span></span> otherwise; region objects are then in the object tree such that
parenthood corresponds to spatial containment. (Note that in I7, a region
must either completely contain another region, or else have no overlap with it.)
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">TestRegionalContainment</span><span class="plain-syntax"> </span><span class="identifier-syntax">obj</span><span class="plain-syntax"> </span><span class="identifier-syntax">region</span><span class="plain-syntax"> </span><span class="identifier-syntax">o</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">obj</span><span class="plain-syntax"> == </span><span class="reserved-syntax">nothing</span><span class="plain-syntax">) || (</span><span class="identifier-syntax">region</span><span class="plain-syntax"> == </span><span class="reserved-syntax">nothing</span><span class="plain-syntax">)) </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="comment-syntax">Set o to the region of the room containing obj</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">obj</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K9_region</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">o</span><span class="plain-syntax"> = </span><span class="reserved-syntax">parent</span><span class="plain-syntax">(</span><span class="identifier-syntax">obj</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">while</span><span class="plain-syntax"> (~~(</span><span class="identifier-syntax">obj</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K1_room</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">obj</span><span class="plain-syntax"> == </span><span class="reserved-syntax">nothing</span><span class="plain-syntax">) </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">obj</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K7_backdrop</span><span class="plain-syntax"> </span><span class="reserved-syntax">or</span><span class="plain-syntax"> </span><span class="identifier-syntax">K4_door</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">obj</span><span class="plain-syntax"> </span><span class="reserved-syntax">has</span><span class="plain-syntax"> </span><span class="identifier-syntax">absent</span><span class="plain-syntax">) </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">objectloop</span><span class="plain-syntax"> (</span><span class="identifier-syntax">o</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K1_room</span><span class="plain-syntax">)</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">TestRegionalContainment</span><span class="plain-syntax">(</span><span class="identifier-syntax">o</span><span class="plain-syntax">, </span><span class="identifier-syntax">region</span><span class="plain-syntax">))</span>
<span class="plain-syntax">                        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">BackdropLocation</span><span class="plain-syntax">(</span><span class="identifier-syntax">obj</span><span class="plain-syntax">, </span><span class="identifier-syntax">o</span><span class="plain-syntax">))</span>
<span class="plain-syntax">                            </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">obj</span><span class="plain-syntax"> = </span><span class="identifier-syntax">HolderOf</span><span class="plain-syntax">(</span><span class="identifier-syntax">obj</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">o</span><span class="plain-syntax"> = </span><span class="identifier-syntax">obj</span><span class="plain-syntax">.</span><span class="identifier-syntax">map_region</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="comment-syntax">Test whether region is, or indirectly contains, o</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">while</span><span class="plain-syntax"> (</span><span class="identifier-syntax">o</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">o</span><span class="plain-syntax"> == </span><span class="identifier-syntax">region</span><span class="plain-syntax">) </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">o</span><span class="plain-syntax"> = </span><span class="reserved-syntax">parent</span><span class="plain-syntax">(</span><span class="identifier-syntax">o</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">SetRegionalContainment</span><span class="plain-syntax"> </span><span class="identifier-syntax">obj</span><span class="plain-syntax"> </span><span class="identifier-syntax">region</span><span class="plain-syntax"> </span><span class="identifier-syntax">o</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">obj</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K1_room</span><span class="plain-syntax">) &amp;&amp; ((</span><span class="identifier-syntax">region</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K9_region</span><span class="plain-syntax">) || (</span><span class="identifier-syntax">region</span><span class="plain-syntax"> == </span><span class="reserved-syntax">nothing</span><span class="plain-syntax">))) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">obj</span><span class="plain-syntax">.</span><span class="identifier-syntax">map_region</span><span class="plain-syntax"> = </span><span class="identifier-syntax">region</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">obj</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K9_region</span><span class="plain-syntax">) &amp;&amp;</span>
<span class="plain-syntax">        ((</span><span class="identifier-syntax">region</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K9_region</span><span class="plain-syntax">) || (</span><span class="identifier-syntax">region</span><span class="plain-syntax"> == </span><span class="reserved-syntax">nothing</span><span class="plain-syntax">))) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">o</span><span class="plain-syntax"> = </span><span class="identifier-syntax">region</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">while</span><span class="plain-syntax"> (</span><span class="identifier-syntax">o</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">o</span><span class="plain-syntax"> == </span><span class="identifier-syntax">obj</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">IssueNoRegionChangeRTP</span><span class="plain-syntax">(</span><span class="identifier-syntax">obj</span><span class="plain-syntax">, </span><span class="identifier-syntax">region</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">o</span><span class="plain-syntax"> = </span><span class="reserved-syntax">parent</span><span class="plain-syntax">(</span><span class="identifier-syntax">o</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">move</span><span class="plain-syntax"> </span><span class="identifier-syntax">obj</span><span class="plain-syntax"> </span><span class="reserved-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">region</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">TestRegionalContainment</span><span class="plain-syntax">(</span><span class="identifier-syntax">obj</span><span class="plain-syntax">, </span><span class="identifier-syntax">region</span><span class="plain-syntax">) == </span><span class="reserved-syntax">false</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">IssueNoRegionChangeRTP</span><span class="plain-syntax">(</span><span class="identifier-syntax">obj</span><span class="plain-syntax">, </span><span class="identifier-syntax">region</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">];</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">IssueNoRegionChangeRTP</span><span class="plain-syntax"> </span><span class="identifier-syntax">obj</span><span class="plain-syntax"> </span><span class="identifier-syntax">region</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">IssueRTP</span><span class="plain-syntax">(</span><span class="string-syntax">"ChangedRegionOfNonRoomOrRegion"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="string-syntax">"Only rooms and regions can change region."</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WorldModelKitRTPs</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="string-syntax">"*** Attempted to move "</span><span class="plain-syntax">, (</span><span class="identifier-syntax">the</span><span class="plain-syntax">) </span><span class="identifier-syntax">obj</span><span class="plain-syntax">, </span><span class="string-syntax">" to "</span><span class="plain-syntax">, (</span><span class="identifier-syntax">the</span><span class="plain-syntax">) </span><span class="identifier-syntax">region</span><span class="plain-syntax">, </span><span class="string-syntax">".^"</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP23" class="paragraph-anchor"></a><b>&#167;23. Doors.</b>There are two sorts of door: one-sided and two-sided.
</p>

<p class="commentary">A two-sided door is in two rooms at once: one is called the front side, the
other the back side. The front side is the one declared first in the source.
Note that a one-sided door is also an I6 object of class <span class="extract"><span class="extract-syntax">K4_door</span></span>, and
then the front side is the room holding it, while the back side is <span class="extract"><span class="extract-syntax">nothing</span></span>.
</p>

<p class="commentary">The <span class="extract"><span class="extract-syntax">door_to</span></span> property calculates the room which the door leads to; that
of course depends on which side of it the player is standing. Similarly,
<span class="extract"><span class="extract-syntax">door_dir</span></span> calculates the direction it leads in. Unlike the I6 setup, where
<span class="extract"><span class="extract-syntax">door_dir</span></span> returned the direction property (<span class="extract"><span class="extract-syntax">n_to</span></span>, <span class="extract"><span class="extract-syntax">s_to</span></span>, etc.), here in
I7's template it returns the direction object (<span class="extract"><span class="extract-syntax">n_obj</span></span>, <span class="extract"><span class="extract-syntax">s_obj</span></span>, etc.)
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">FrontSideOfDoor</span><span class="plain-syntax"> </span><span class="identifier-syntax">D</span><span class="plain-syntax">; </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (~~(</span><span class="identifier-syntax">D</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K4_door</span><span class="plain-syntax">)) </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">D</span><span class="plain-syntax"> </span><span class="reserved-syntax">provides</span><span class="plain-syntax"> </span><span class="identifier-syntax">found_in</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> (</span><span class="identifier-syntax">D</span><span class="plain-syntax">.&amp;</span><span class="identifier-syntax">found_in</span><span class="plain-syntax">)--&gt;0; </span><span class="comment-syntax">Two-sided</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="reserved-syntax">parent</span><span class="plain-syntax">(</span><span class="identifier-syntax">D</span><span class="plain-syntax">); </span><span class="comment-syntax">One-sided</span>
<span class="plain-syntax">];</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">BackSideOfDoor</span><span class="plain-syntax"> </span><span class="identifier-syntax">D</span><span class="plain-syntax">; </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (~~(</span><span class="identifier-syntax">D</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K4_door</span><span class="plain-syntax">)) </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">D</span><span class="plain-syntax"> </span><span class="reserved-syntax">provides</span><span class="plain-syntax"> </span><span class="identifier-syntax">found_in</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> (</span><span class="identifier-syntax">D</span><span class="plain-syntax">.&amp;</span><span class="identifier-syntax">found_in</span><span class="plain-syntax">)--&gt;1; </span><span class="comment-syntax">Two-sided</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="reserved-syntax">nothing</span><span class="plain-syntax">; </span><span class="comment-syntax">One-sided</span>
<span class="plain-syntax">];</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">OtherSideOfDoor</span><span class="plain-syntax"> </span><span class="identifier-syntax">D</span><span class="plain-syntax"> </span><span class="identifier-syntax">from_room</span><span class="plain-syntax"> </span><span class="identifier-syntax">rv</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">D</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K4_door</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        @</span><span class="identifier-syntax">push</span><span class="plain-syntax"> </span><span class="identifier-syntax">location</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">location</span><span class="plain-syntax"> = </span><span class="identifier-syntax">LocationOf</span><span class="plain-syntax">(</span><span class="identifier-syntax">from_room</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">rv</span><span class="plain-syntax"> = </span><span class="identifier-syntax">D</span><span class="plain-syntax">.</span><span class="identifier-syntax">door_to</span><span class="plain-syntax">();</span>
<span class="plain-syntax">        @</span><span class="identifier-syntax">pull</span><span class="plain-syntax"> </span><span class="identifier-syntax">location</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">rv</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">DirectionDoorLeadsIn</span><span class="plain-syntax"> </span><span class="identifier-syntax">D</span><span class="plain-syntax"> </span><span class="identifier-syntax">from_room</span><span class="plain-syntax"> </span><span class="identifier-syntax">rv</span><span class="plain-syntax"> </span><span class="identifier-syntax">dir</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">D</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K4_door</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        @</span><span class="identifier-syntax">push</span><span class="plain-syntax"> </span><span class="identifier-syntax">location</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">location</span><span class="plain-syntax"> = </span><span class="identifier-syntax">LocationOf</span><span class="plain-syntax">(</span><span class="identifier-syntax">from_room</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">rv</span><span class="plain-syntax"> = </span><span class="identifier-syntax">D</span><span class="plain-syntax">.</span><span class="identifier-syntax">door_dir</span><span class="plain-syntax">();</span>
<span class="plain-syntax">        @</span><span class="identifier-syntax">pull</span><span class="plain-syntax"> </span><span class="identifier-syntax">location</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">rv</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP24" class="paragraph-anchor"></a><b>&#167;24. Visibility Relation.</b>We use <span class="extract"><span class="extract-syntax">TestScope</span></span> to decide whether there is a line of sight from A to B;
it's a relation which cannot be asserted true or false.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">TestVisibility</span><span class="plain-syntax"> </span><span class="identifier-syntax">A</span><span class="plain-syntax"> </span><span class="identifier-syntax">B</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">A</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K2_thing</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">B</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K2_thing</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (~~</span><span class="identifier-syntax">OffersLight</span><span class="plain-syntax">(</span><span class="reserved-syntax">parent</span><span class="plain-syntax">(</span><span class="identifier-syntax">CoreOf</span><span class="plain-syntax">(</span><span class="identifier-syntax">A</span><span class="plain-syntax">)))) </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">suppress_scope_loops</span><span class="plain-syntax">) </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">TestScope</span><span class="plain-syntax">(</span><span class="identifier-syntax">B</span><span class="plain-syntax">, </span><span class="identifier-syntax">A</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP25" class="paragraph-anchor"></a><b>&#167;25. Audibility Relation.</b>For now, this is the same test as visibility except that it does not require
light to see by.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">TestAudibility</span><span class="plain-syntax"> </span><span class="identifier-syntax">A</span><span class="plain-syntax"> </span><span class="identifier-syntax">B</span><span class="plain-syntax"> </span><span class="identifier-syntax">res</span><span class="plain-syntax"> </span><span class="identifier-syntax">saved</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">suppress_scope_loops</span><span class="plain-syntax">) </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">A</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K2_thing</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">B</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K2_thing</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">saved</span><span class="plain-syntax"> = </span><span class="identifier-syntax">location</span><span class="plain-syntax">; </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">location</span><span class="plain-syntax"> == </span><span class="identifier-syntax">thedark</span><span class="plain-syntax">) </span><span class="identifier-syntax">location</span><span class="plain-syntax"> = </span><span class="identifier-syntax">real_location</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">res</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TestScope</span><span class="plain-syntax">(</span><span class="identifier-syntax">B</span><span class="plain-syntax">, </span><span class="identifier-syntax">A</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">location</span><span class="plain-syntax"> = </span><span class="identifier-syntax">saved</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">res</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP26" class="paragraph-anchor"></a><b>&#167;26. Touchability Relation.</b>We use <span class="extract"><span class="extract-syntax">ObjectIsUntouchable</span></span> to decide whether there is physical access from
A to B; it's a relation which cannot be asserted true or false.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">TestTouchability</span><span class="plain-syntax"> </span><span class="identifier-syntax">A</span><span class="plain-syntax"> </span><span class="identifier-syntax">B</span><span class="plain-syntax"> </span><span class="identifier-syntax">rv</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (~~((</span><span class="identifier-syntax">A</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K2_thing</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">B</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K2_thing</span><span class="plain-syntax">))) </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">A</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K4_door</span><span class="plain-syntax"> </span><span class="reserved-syntax">or</span><span class="plain-syntax"> </span><span class="identifier-syntax">K7_backdrop</span><span class="plain-syntax">) </span><span class="identifier-syntax">MoveFloatingObjects</span><span class="plain-syntax">(</span><span class="identifier-syntax">LocationOf</span><span class="plain-syntax">(</span><span class="identifier-syntax">B</span><span class="plain-syntax">));</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">B</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K4_door</span><span class="plain-syntax"> </span><span class="reserved-syntax">or</span><span class="plain-syntax"> </span><span class="identifier-syntax">K7_backdrop</span><span class="plain-syntax">) </span><span class="identifier-syntax">MoveFloatingObjects</span><span class="plain-syntax">(</span><span class="identifier-syntax">LocationOf</span><span class="plain-syntax">(</span><span class="identifier-syntax">A</span><span class="plain-syntax">));</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">TestScope</span><span class="plain-syntax">(</span><span class="identifier-syntax">B</span><span class="plain-syntax">,</span><span class="identifier-syntax">A</span><span class="plain-syntax">) == </span><span class="reserved-syntax">false</span><span class="plain-syntax">) </span><span class="identifier-syntax">rv</span><span class="plain-syntax"> = </span><span class="reserved-syntax">true</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="identifier-syntax">rv</span><span class="plain-syntax"> = </span><span class="identifier-syntax">ObjectIsUntouchable</span><span class="plain-syntax">(</span><span class="identifier-syntax">B</span><span class="plain-syntax">, </span><span class="reserved-syntax">true</span><span class="plain-syntax">, </span><span class="identifier-syntax">A</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">A</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K4_door</span><span class="plain-syntax"> </span><span class="reserved-syntax">or</span><span class="plain-syntax"> </span><span class="identifier-syntax">K7_backdrop</span><span class="plain-syntax">) </span><span class="identifier-syntax">MoveFloatingObjects</span><span class="plain-syntax">();</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">rv</span><span class="plain-syntax">) </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP27" class="paragraph-anchor"></a><b>&#167;27. Concealment Relation.</b>An activity determines whether one object conceals another; it's a relation
which cannot be asserted true or false.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">TestConcealment</span><span class="plain-syntax"> </span><span class="identifier-syntax">A</span><span class="plain-syntax"> </span><span class="identifier-syntax">B</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">A</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K2_thing</span><span class="plain-syntax"> &amp;&amp; </span><span class="identifier-syntax">B</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">K2_thing</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">IndirectlyContains</span><span class="plain-syntax">(</span><span class="identifier-syntax">A</span><span class="plain-syntax">, </span><span class="identifier-syntax">B</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">particular_possession</span><span class="plain-syntax"> = </span><span class="identifier-syntax">B</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">CarryOutActivity</span><span class="plain-syntax">(</span><span class="identifier-syntax">DECIDING_CONCEALED_POSSESS_ACT</span><span class="plain-syntax">, </span><span class="identifier-syntax">A</span><span class="plain-syntax">)) </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>
</pre>
<nav role="progress"><div class="progresscontainer">
    <ul class="progressbar"><li class="progressprev"><a href="prntn.html">&#10094;</a></li><li class="progresssection"><a href="mscll.html">mscll</a></li><li class="progresssection"><a href="stt.html">stt</a></li><li class="progresssection"><a href="lght.html">lght</a></li><li class="progresssection"><a href="lstwr.html">lstwr</a></li><li class="progresssection"><a href="ordrf.html">ordrf</a></li><li class="progresssection"><a href="actns.html">actns</a></li><li class="progresssection"><a href="fgrs.html">fgrs</a></li><li class="progresssection"><a href="otfwr.html">otfwr</a></li><li class="progresssection"><a href="prntn.html">prntn</a></li><li class="progresscurrent">wrldm</li><li class="progresssection"><a href="mprtf.html">mprtf</a></li><li class="progresssection"><a href="tm.html">tm</a></li><li class="progresssection"><a href="tsts.html">tsts</a></li><li class="progresssection"><a href="chrnl.html">chrnl</a></li><li class="progresssection"><a href="strdc.html">strdc</a></li><li class="progressnext"><a href="mprtf.html">&#10095;</a></li></ul></div>
</nav><!-- End of weave -->

		</main>
	</body>
</html>

